<template>
  <div class="flex" id="home" @click="hiddenAll" ref="select_frame">
    <!-- <assectNewSearch :isAssectSearchShow.sync='isAssectSearchShow' v-show="newSearchShow"
      @showSearchWindow='showSearchWindow'></assectNewSearch>
    <assectSeachWindow @lookOffic='lookOffic' @transmitAppName='openApp' :type='searchType' v-show="isAssectSearchShow"
      :isAssectSearchShow.sync='isAssectSearchShow'></assectSeachWindow> -->
    <!-- zk129新增，版本更新提示，显示条件1.已经获取到了新版信息2.允许显示(点击关闭时控制显隐)3.当前版不是最新版 暂未启用 -->
    <newVersionTip :Version="Version" @toNewVersion="toNewVersion" :showNewVersion.sync="showNewVersion"
      :newVersionDetail="newVersionDetail"></newVersionTip>

    <div v-if="login2">
      <Member-cards v-if="searchTargetShow" :viewTarget="searchviewTarget" :ifLinkman="ifLinkman" :toInfo="toInfo"
        @click.stop.prevent="" @personItem="personItem" @newChat="newChat(arguments)"
        @cardClose="searchTargetShow = false" @addLinkman="addLinkman"></Member-cards>
      <!-- 综合搜索 -->
      <Search-show ref="cSearchShow" v-show="isSearchShow && searchResultShow" :setHistoryMsg="setHistoryMsg"
        :isListSider="isListSider" :toInfo="toInfo" :playerOptions="playerOptions"
        :isSearchShows="isSearchShow && searchResultShow" @toggleListSider="isListSider = !isListSider"
        @inputClick="inputClick" @showClose="isSearchShow = false" @searchMdbTochat="searchMdbTochat"
        @toForwarding="toForwarding" @toDownFile="toDownFile" @downloadListAddProcess="downloadListAddProcess"
        @chatFunctionHandle="chatFunctionHandle" @addBacklogShow="addBacklogShow">
      </Search-show>
      <!--设备信息 -->
      <EquipmentInformation :deviceInfo="deviceInfo" :deviceInfoShow.sync="deviceInfoShow"></EquipmentInformation>
    </div>
    <div class="rawModal" v-show="modalFirst" @click="modalFirst = false"></div>
    <!-- 左侧边栏 -->
    <home-sider :imgLoading="imgLoading" v-if="pageFlagShow" :sessionList="sessionList" :personalStatus="personalStatus"
      :config_active="config_active" :broadNoRead="broadNoRead" :isUpdateExeShow="isUpdateExeShow"
      :officialManageTotal="officialManageTotal" @toMyInfo="toMyInfo" @setSider="setSider"
      @set_sure_state="set_sure_state" @cancel_state_update="cancel_state_update" @setModalFirst="setModalFirst"
      @showService="showService" @configMain_show="configMain_show" @toSetStatus="toSetStatus" @editShowFn="editShowFn"
      @fileChange="fileChange" @check_state_value="check_state_value" :cur_state="cur_state" :state_show="state_show"
      :siderArray="siderArray" :myCardShow="myCardShow" :showUpdatePicForm="showUpdatePicForm">
    </home-sider>
    <!-- 右侧栏 -->
    <div class="homeHeader" ref="main">
      <div class="homeHeaderSecond">
        <!-- 会话列表 zk1211新增:toExpression = "toExpression"，解决左侧表情不显示-->
        <session-list-sider v-show="isListSider" @transmitAppName="openApp" :sessionList="sessionList"
          :siderArray="siderArray" :free_list="free_list" :setaList="setaList" :bookList="bookList" :workList="workList"
          :minorShow="minorShow" :searchResultShow="searchResultShow" :searchUserList="searchUserList"
          :officialManageTotal="officialManageTotal" :screenPersonList="screenPersonList"
          :oldScreenPersonList="oldScreenPersonList" :isUpdateUser="isUpdateUser" :isAutoOpenScreen="isAutoOpenScreen"
          @search_list_array_user="search_list_array_user" @searchMdbTochat="searchMdbTochat" @toNewChat="toNewChat"
          @searchFocus="searchFocus" @setStructureListShow="setStructureList(arguments)"
          @setWorkListShow="setWorkListShow(arguments)" @updateSessionMessageFree="updateSessionMessageFree(arguments)"
          @getSetaTop="getSetaTop" @toChat="sessionToChat" @chatingFun="chatingFun"
          @searchToView="searchViewShow(arguments)" @inputClick="inputClick" @changeShow="changeShow"
          :toExpression="toExpression" @toDetail="toDetail" @setSearchArray="setSearchArray" :hideSearch="hideSearch"
          @getPersonFn="getPersonFn" @openBroadItem="openBroadItem" @initIsAutoOpenScreen="initIsAutoOpenScreen"
          @openSearchTab="openSearchTab" @setBookListShow="openBookList" @workListShow="openListShow">
        </session-list-sider>
        <!-- zk注释，homeMain右侧主体 -->
        <div class="homeMain" ref="homeMain" v-show="chating && siderArray[0].active">
          <div class="homeMainHeader" v-if="login1">
            <!-- 聊天内容头部 -->

            <header-parent @getAndSaveUserInfo="getAndSaveUserInfo" @toChat="toChat" @workListShow="workListShow"
              @openOfficialBox="openOfficialBox" :sessionList="sessionList" :messageTipsArr="messageTipsArr"
              @hiddenAll="hiddenAll" :requestUser="requestUser" :remoteType="remoteType" :remoteState.sync="remoteState"
              :control_type.sync="control_type" @viewUpdate="viewUpdate" :shareImgList="shareImgList" :chatList="chatList"
              :broad_show_item="broad_show_item" @broadForceUpdate="broadForceUpdate" :downloadList="downloadList"
              :sqlTable="sqlTable" @updateSessionChat="updateSessionChat" @insertData="insertData" :ws="ws"
              :myInfo="myInfo" @sortSessionList="sortSessionList" :toForwardingLocal.sync="toForwardingLocal"
              :updateFileList="updateFileList" :isToForwardingLocal="isToForwardingLocal" :ifLinkman="ifLinkman"
              :toInfo="toInfo" :files_show="files_show" :group_info_show="group_info_show" :isDissolve="isDissolve"
              :toInfoHeadPath="toInfoHeadPath" :isDepartmentShow="isDepartmentShow" @filesActive="filesActive"
              @toGroupFunction="toGroupFunction" @chatFunClick="chatFunClick" @chat_view_target="chat_view_target"
              @setSider="setSider" @openTreeList="openTreeList" @changeIsDepartmentShow="changeIsDepartmentShow">
            </header-parent>
            <div class="home_chat_main">
              <div class="home_chat_section">
                <!-- 聊天设置 -->
                <!-- @editMenuShow="editMenuShow(arguments)" -->
                <chat-settings v-if="group_info_show" @click.native.stop.prevent="" @shareCode="shareCode"
                  @delMemberViewActive="delMemberViewActive" @qrcodeShow="qrcodeShow" @close_group_info="close_group_info"
                  @getMemberInfo="getMemberInfoFn(arguments)" @updateTopChat="updateTopChat"
                  @updateMessageFree="updateMessageFree" @clear_records="clear_records" @addMember="addMember"
                  @viewTargetHide="viewTargetHide" @setMyposition="setMyposition" @getGroupUser="getGroupUser"
                  @getGroupList="getGroupList" :isDissolve="isDissolve" :group_info="group_info"
                  :group_detail="group_detail" :group_info_show="group_info_show" :my_position="my_position"
                  :chatList="chatList" :sessionList="sessionList" :topChat="topChat" :messageFree="messageFree"
                  :toInfo="toInfo" :setaList="setaList" :editPositionShow="editPositionShow">
                </chat-settings>
                <!-- 已读未读列表 -->
                <read-consult v-if="read_info_show" @click.native.stop.prevent="" :unreadUsers="unreadUsers"
                  @changeActive="changeActive" :showDownloadData="showDownloadData" :activeIndex="activeIndex"
                  :readUsers="readUsers" :group_unread="group_unread" :group_read="group_read"></read-consult>
                <!-- 聊天主内容显示 zk新增，将群语录传递给homechatmain组件:list="allQuotationsList" :regUrl = "regUrl" -->
                <home-chat-main ref="homeChatMain" v-if="pageFlagShow" :expression="expression"
                  :playerOptions="playerOptions" :toInfo="toInfo" :personalStatus="personalStatus" :ifLinkman="ifLinkman"
                  :show_index="show_index" :chatList="chatList" :free_list="free_list" :group_info_show="group_info_show"
                  :my_position="my_position" :sessionList="sessionList" :setaList="setaList" :messageFree="messageFree"
                  :isMultiSelect="isMultiSelect" :chatFunctionActive="chatFunctionActive" :toInfoHeadPath="toInfoHeadPath"
                  :unreadUsers="unreadUsers" @againSendFailMsg="againSendFailMsg" @getGroupInfo="getGroupInfo"
                  @getCollect="getCollect" @chatFunctionHandle="chatFunctionHandle" @setchatChooseList="setchatChooseList"
                  @setChatList="setChatList" @multiSelectClick="multiSelectClick"
                  @downloadListAddProcess="downloadListAddProcess" @addBacklogShow="addBacklogShow"
                  @getMemberInfo="getMemberInfoFn(arguments)" @showMap="showMap" @toDownFile="toDownFile"
                  @toForwarding="toForwarding" @toForwardingLocalData="toForwardingLocalData" @toDelChat="toDelChat"
                  @messageScrollChange="messageScrollChange" @messageScrollChangeBottom="messageScrollChangeBottom"
                  :group_detail="group_detail" @readView="readView" @openLinkFn="openLinkFn"
                  :currentTempChat="currentTempChat" @getTop="getTop" @getBottom="getBottom"
                  :currentNewsId="currentNewsId" :activeRecords="activeRecords" @changeProp="changeProp"
                  @backBottom="backBottom" @switchChatMain="switchChatMain" :firstUnreadId="firstUnreadId">
                </home-chat-main>
                <!--聊天发送-->
                <news-editor ref="newsEditor" v-show="!isMultiSelect" :senHot="senHot" :copyShow="copyShow"
                  :control_show="control_show" :isScreenshot="isScreenshot" :currentTempChat="currentTempChat"
                  @storageSqlSendText="storageSqlSendText" @updateChatList="updateChatList" @updateFile="updateFile"
                  @controlActive="controlActive" @controlFn="controlFn" @screenFn="screenFn"
                  @copyShowClick="copyShowClick" @groupNoticeClick="groupNoticeClick" @updateDropState="updateDropState"
                  @newSessionSort="newSessionSort" :siderArray="siderArray" :isOndropHandle="isOndropHandle"
                  :clipBoardFile="clipBoardFile" :messageFree="messageFree" :toInfo="toInfo" :contentReset="contentReset"
                  :quickShow="quickShow" :faceShow="faceShow" :personalStatus="personalStatus" :chatList="chatList"
                  :sessionList="sessionList" :specified_show="specified_show" :group_detail="group_detail"
                  :activeRecords="activeRecords" :free_list="free_list" :expression="expression" :isDissolve="isDissolve"
                  :myposition="my_position" @updateMessageFree="updateMessageFree"
                  @content_input_focus="content_input_focus" @toGroupFunction="toGroupFn(arguments)"
                  @resetUp_DownFlag="resetUp_DownFlag" @changeShow="changeShow" :pageFlagShow="siderArray[0].active"
                  @toForwarding="toForwarding" @backBottom="backBottom" @chatScrollToBottom="chatScrollToBottom"></news-editor>
                <!-- 多选收藏删除 -->
                <mySelectDelOrCol :currentTempChat="currentTempChat" :sessionList="sessionList" :chatList="chatList"
                  @getCollect="getCollect" :myInfo="myInfo" :sqlTable="sqlTable" :toInfo="toInfo"
                  :chatChooseList="chatChooseList" @forwardMore="forwardMore" :isMultiSelect.sync="isMultiSelect">
                </mySelectDelOrCol>
              </div>
              <!-- 历史消息 zk新增@switchChatMain跳转到某条历史记录-->
              <historical-news v-if="activeRecords" @closeHistorical="closeHistorical" @toDownFile="toDownFile"
                @toGroupFunction="toGroupFunction" :playerOptions="playerOptions" :fullState="fullState" :toInfo="toInfo"
                :chating="chating" :siderArray="siderArray" :activeRecords="activeRecords"
                :personal_chat_list="personal_chat_list" :expression="expression" :start_time="start_time"
                :end_time="end_time" @switchChatMain="switchChatMain" @toForwarding="toForwarding"></historical-news>
              <!-- 重点语录 -->
              <quotations ref="quotations" v-if="quotationsShow" @closeCornal="closeCornal" @allQuotations="allQuotations"
                @delteleQuotation="delteleQuotation" @searchKeyWords="searchKeyWords" :position="my_position"
                :cornalShow="cornalShow" :groupInfo="toInfo" :list="allQuotationsList" :canDelete="this.my_position != 3">
              </quotations>
            </div>
          </div>
        </div>
        <div v-if="broad_detail_show">
          <!-- zk0301修改:broad_show_item="broad_show_item_index?broadList[broad_show_item_index]:broad_show_item" 针对点击搜索结果无法打开广播的问题 -->
          <broad-detail v-show="broad_show_item && broadFlagShow" :list.sync="broadList" :pageBroadList="pageBroadList"
            :broad_show_item_index.sync="broad_show_item_index" :broad_show_item="broad_show_item_index
              ? broadList[broad_show_item_index]
              : broad_show_item
              " @pageIndex="pageIndex" @broadClose="broadClose" @downloadListAddProcess="downloadListAddProcess"
            @click.native.stop.prevent="" @broadDelete="broadDelete" @searchBroadList="searchBroadList"
            @newPageFn="newPageFn"></broad-detail>
        </div>
        <!-- 常用联系人 -->
        <book-tp v-show="bookList[0].show && siderArray[1].active" :type="1">
          <Frequent-Contacts :friendsGroup="friendsGroup" @friendEditPosition="friendEditPosition" @toNewChat="toNewChat"
            @dbtoNewChat="dbtoNewChat">
          </Frequent-Contacts>
        </book-tp>
        <!--我的群组-->
        <book-tp v-show="bookList[1].show && siderArray[1].active" :type="2">
          <My-groups :groupList="groupList" @toNewChat="toNewChat"> </My-groups>
        </book-tp>
        <!--发送广播-->
        <broad-send v-show="workList[0].show && siderArray[2].active" :broadSendAct="siderArray[2].active"
          :broadSendShow="workList[0].show" @setClose="setClose" @setModalFirst="setModalFirst" :list="broadSendList"
          @sendCancel="sendCancel" :ws="ws" :key="broadKey" ref="broadChild" :toInfo="toInfo" @updateBroad="updateBroad"
          @resetModalFirst="resetModalFirst"></broad-send>
        <!--组织架构-->
        <book-tp v-show="siderArray[1].active && bookList[2].show" :type="3">
          <structure-main :addUserDisabled="addUserDisabled" :bookList="bookList"
            @search_list_array_user="search_list_array_user" @searchToView="searchViewShow(arguments)"
            @searchMdbTochat="searchMdbTochat">
          </structure-main>
        </book-tp>

        <!-- 广播消息 -->
        <book-tp v-show="workList[1].show && siderArray[2].active" :type="0">
          <myBroadcastnotification ref="myBroadcastnotification" @deleteBroadItem="deleteBroadItem"
            @setBroadItem="setBroadItem" :broadListFlagShow="broadListFlagShow" :pageBroadList.sync="pageBroadList"
            :pageSize="pageSize" :files_cur.sync="files_cur" @editBroadList="editBroadList"
            :broadNoRead.sync="broadNoRead" :workList="workList" :sqlTable="sqlTable" :broadTotal.sync="broadTotal"
            :broad_show_item_index="broad_show_item_index" :broad_show_item="broad_show_item" :broadList="broadList"
            @initPage="initPage" :departmentValue.sync="departmentValue"></myBroadcastnotification>
        </book-tp>

        <!-- 收发文件 -->
        <book-tp v-show="workList[2].show && siderArray[2].active" :type="4">
          <files-examine @toForwarding="toForwarding" @toDownFile="toDownFile" :isResetFiles="isResetFiles"
            @forwardingSet="forwardingSet" :isShow="workList[2].show ? true : false"></files-examine>
        </book-tp>
        <!-- 共享文件 -->
        <book-tp v-if="workList[3].show && siderArray[2].active" :type="6">
          <iframe v-if="iframeSrc" :src="iframeSrc" class="iframeSrc" id="iframe" frameborder="0"></iframe>
        </book-tp>
        <!-- 我的部门 -->
        <book-tp v-show="bookList[3].show && siderArray[1].active" :type="5">
          <div class="communication_wrap">
            <div class="loading_department">
              <department-list v-for="(temp, dep) in bookList[3].myDepartment" @viewUpdate="viewUpdate"
                :currentStructureIndex.sync="currentStructureIndex" :currentStructureName="currentStructureName"
                @downLoadHeadPath="downLoadHeadPath" :viewTargetShow.sync="viewTargetShow" @isLinkman="isLinkman"
                :viewTarget.sync="viewTarget" :sqlTable="sqlTable" @getCurCoor="getCurCoor"
                :clickIntervale.sync="clickIntervale" :index="dep" :item="temp" :searchUserList="searchUserList"
                @dbtoNewChats="dbtoNewChats(arguments)" @tonextstr="tonextstr(arguments)" :key="dep + 'str'">
              </department-list>
            </div>
          </div>
        </book-tp>
        <!-- 系统消息 -->
        <book-tp v-show="systemShow && siderArray[0].active" :type="7">
          <System-Notice :groupNews="groupNews" :auditNotice="auditNotice" @addMemberOption="addMemberOption"
            @newsInfo="newsInfo"></System-Notice>
        </book-tp>
        <!-- 我的收藏 -->
        <book-tp v-show="workList[4].show && siderArray[2].active" :type="8">
          <My-collection :playerOptions="playerOptions" @remindSearchFn="remindSearchFn" ref="isMycollection"
            :downLoadHeadPath="downLoadHeadPath" :toInfo="toInfo" @downloadListAddProcess="downloadListAddProcess"
            @openLinkFn="openLinkFn" @toForwarding="toForwarding"></My-collection>
        </book-tp>
        <!-- 我的待办 -->
        <offdoc @getType='getType' @transmitAppName="openApp" v-if="workList[5].show && siderArray[2].active"
          @updateIsDone="updateIsDone" @delRemind="delRemind" @addRemind="addRemind" ref="offdoc" :formMsgs="formMsgs"
          :flags="flags" @setOfficialFileSQL="setOfficialFileSQL" @downloadListAddProcess="downloadListAddProcess"
          :downLoadFileList="downLoadFileList" :officialManageTotal.sync="officialManageTotal"></offdoc>
        <!-- 我的日程 -->
        <book-tp v-show="workList[6].show && siderArray[2].active" :type="10">
          <my-curriculum @scheduleSel="scheduleSel" @pickNext="pickNext" @pickPre="pickPre" @daysClick="daysClick"
            :newScheduleList="newScheduleList" :programmeTimeList="programmeTimeList" :currentWeek="currentWeek"
            :weekKV="weekKV" @newCalendarClick="newCalendarClick" :currentYear="currentYear" :currentDay="currentDay"
            :currentMonth="currentMonth" :days="days" :currentDayIndex="currentDayIndex" @initToday="initToday">
          </my-curriculum>
        </book-tp>
        <!-- 我的文章 -->
        <book-tp v-if="workList[7].show && siderArray[2].active" :type="11" :article_editor_show="article_editor_show"
          @changeEditor="changeEditor">
          <myArticle @pageChange='pageChange' @getPageNum='getPageNum' @setModalFirst='setModalFirst'
            @changeEditor='changeEditor' ref="myArticle" @revocationArticleFn='revocationArticleFn'
            @deleteArticleInit='deleteArticleInit' :myInfo='myInfo' :sqlTable='sqlTable' @goPage='goPage'
            :files_cur.sync='files_cur' @openLinkFn='openLinkFn' :pageSize='pageSize'
            :articleTitleTime.sync='articleTitleTime' :articleSendList='articleSendList' @initPage='initPage'
            :article_editor_show='article_editor_show'></myArticle>
        </book-tp>
        <!-- 公文管理 -->
        <book-tp v-if="workList[8].show && siderArray[2].active" :type="12" :article_editor_show="article_editor_show"
          @changeEditor="changeEditor">
          <iframe :src="iframeOfficial" class="iframeSrc" id="iframeOfficial" frameborder="0"></iframe>
        </book-tp>
        <!-- 资产申请 -->
        <!-- <book-tp v-if="workList[12].show && siderArray[2].active" :type="12" :article_editor_show="article_editor_show" @changeEditor="changeEditor">

          <iframe :src="iframeAssetApplication" class="iframeSrc" id="iframeOfficial" frameborder="0"></iframe>
        </book-tp> -->

        <!-- 资产待办 -->
        <book-tp @assectGoback='assectGoback' :assectName='assectName'
          v-if="(workList[13].show || workList[14].show || workList[15].show || workList[16].show || workList[17].show || workList[18].show || workList[19].show || workList[20].show) && siderArray[2].active"
          :type="15">
          <template slot-scope="{assectName}">

            <assectToExamine :actName='actName' :instanceId='instanceId' @assectGoback='assectGoback'
              :assectForm='assectForm' :accName='assectName'></assectToExamine>
          </template>
        </book-tp>

        <!-- 远程控制 -->
        <Remote v-if="workList[9].show && siderArray[2].active"></Remote>
        <!-- 同屏观看 -->
        <Screen ref="screen" v-show="workList[10].show && siderArray[2].active" :screenPersonList="screenPersonList"
          :sessionList="sessionList" :isUpdateUser="isUpdateUser" :oldScreenPersonList="oldScreenPersonList"
          :isAutoOpenScreen="isAutoOpenScreen" :globalOverScreen="globalOverScreen" @getPersonFn="getPersonFn"
          @globalOverScreenFn="globalOverScreenFn"></Screen>
      </div>
    </div>
    <!-- 查看对方资料卡 -->
    <member-card v-if="viewTargetShow" :viewTarget="viewTarget" :ifLinkman="ifLinkman" :toInfo="toInfo"
      :style="{ top: toInfoTop + 'px', left: toInfoLeft + 'px' }" style="position: absolute; z-index: 1300"
      @click.stop.prevent="" @personItem="personItem" @newChat="newChat(arguments)" @cardClose="cardClose">
    </member-card>
    <!--删除功能项-->
    <delete-item @setClose="setClose" v-if="deleteShow" :content="deleteContent"></delete-item>
    <!--系统设置项-->
    <system-item :messageTipsArr="messageTipsArr" @setClose="setClose" @setSendHot="setSendHot" v-if="windowStatus"
      @getSessionList="getSessionList">
    </system-item>
    <!--修改密码项-->
    <!-- <pass-word @setClose='setClose' v-if='passwordStatus' :key='new Date().getTime()'></pass-word> -->
    <pass-word @setClose="setClose" v-if="passwordStatus"></pass-word>
    <!--清除缓存项-->
    <clear-item @setClose="setClearClose" title="清除缓存" content="是否确认清除所有即时通讯数据(包括聊天记录等、快捷键设置等)？清除后将会重置到新安装状态"
      @setConfirm="setConfirm" v-if="clearStatus"></clear-item>
    <!-- 加入群聊 -->
    <join-group @setClose="showJoinGroup = false" title="提示" :content="`是否加入群聊&quot;${shareGroupInfo.value.shareGroupName || ''
      }&quot;`" @setConfirm="confirmJoinGroup" v-if="showJoinGroup"></join-group>
    <!-- 群公告 -->
    <notice-delete @setClose="noticeConfirm = false" title="提示" content="确定删除当前公告?" @setConfirm="deleteNotice"
      v-if="noticeConfirm"></notice-delete>
    <!--创建聊天modal-->
    <!-- <modal-view
			@getGroupAndUsers='getGroupAndUsers'
			:forwarding_array='forwarding_array'
			:friendsList='friendsList'
			:personalStatus='personalStatus'
			:modalFirst='modalFirst'
			:modalTitle='modalTitle'
			:personCount='personCount'
			:modalSearchResult='modalSearchResult'
		></modal-view> -->
    <!-- S 选择发送、转发对象弹窗 -->
    <Modal draggable v-model="modalFirst" id="ModalFirst" :styles="{ top: '50px' }" @on-cancel="resetModalFirst">
      <modlaFirst ref="modlaFirst" @modalFirstCancel="modalFirstCancel" :sessionList="sessionList"
        @updateSessionChat="updateSessionChat" :sqlTable="sqlTable" :groupList="groupList"
        @delCheckPerson="delCheckPerson" @checkPersonArrayPush="checkPersonArrayPush" :defaultImg="defaultImg"
        :friendsGroup="friendsGroup" :group_detail="group_detail" @downLoadHeadPath="downLoadHeadPath"
        :toForwardingLocal="toForwardingLocal" :chatChooseList.sync="chatChooseList"
        :isToForwardingLocal.sync="isToForwardingLocal" :isMultiSelect.sync="isMultiSelect" @resetContacts="resetContacts"
        :broadSendList.sync="broadSendList" @getGroupUser="getGroupUser" @getGroupList="getGroupList"
        @resetModalFirst="resetModalFirst" :shareFileArr="shareFileArr" :ws="ws" :shareInfo="shareInfo"
        :shareChoosed="shareChoosed" :isShare="isShare" :participant.sync="participant" :modalFirst.sync="modalFirst"
        :addUserDisabled.sync="addUserDisabled" :personalStatus="personalStatus" :toInfo="toInfo"
        :modalFirstList="modalFirstList" :modalCheckArray="modalCheckArray" :articleSendList.sync="articleSendList"
        :checkPersonArray.sync="checkPersonArray" :myInfo="myInfo" :modalTitle="modalTitle"
        :forwardingList="forwardingList" :screenFlag="screenFlag" :screenPersonList.sync="screenPersonList">
      </modlaFirst>
    </Modal>
    <!-- E 选择发送、转发对象弹窗 -->
    <!-- 地图显示隐藏 -->
    <map-view :mapData="mapData" v-if="show_map" @closeMap="closeMap"></map-view>
    <!-- 二维码扫一扫 -->
    <qrcode v-if="appShow" @qrcodeClose="qrcodeClose"
      value="http://192.168.1.139/group1/M01/00/08/wKgBi13KaGKAITr8A7y5PclTYus165.apk" :size="240"></qrcode>
    <!-- 群二维码分享 -->
    <group-qrcode v-if="groupCodeShow" :value="groupCode" :title="'扫一扫入群'" :content="'手机扫描二维码入群'"
      @qrcodeClose="qrcodeClose" :size="240"></group-qrcode>
    <!-- 替换头像 -->
    <update-avatar v-show="cropper_show" @croppet_cfg="croppet_cfg" @cropper_hide="cropper_hide">
      <vueCropper ref="cropper" :img="option.img" :outputSize="option.size" :outputType="option.outputType"
        :full="option.full" :canMove="option.canMove" :canMoveBox="option.canMoveBox" :original="option.original"
        :autoCrop="option.autoCrop" :autoCropWidth="option.autoCropWidth" :autoCropHeight="option.autoCropHeight"
        :fixedBox="option.fixedBox" :info="option.info" :centerBox="option.centerBox" :fixed="option.fixed">
      </vueCropper>
    </update-avatar>

    <!-- 系统设置 -->
    <div class="system_list_wrap" v-show="config_active">
      <ul>
        <li v-for="(item, index) in configList" @click.stop.prevent="congfigItemClick(index)" :key="'config' + index">
          <img :src="item.url" /><span>{{ item.title }}</span>
          <img class="updateImg" v-if="index == 2 && isUpdateExeShow" src="static/image/home/updateExe/set_new.png" />
        </li>
      </ul>
    </div>

    <!-- 版本升级弹框手动检测 -->
    <detectUpgrade :Version="Version" :updateExeShow.sync="updateExeShow"></detectUpgrade>

    <!-- 强制版本升级弹框 zk0201替换成新版class = new_version_tip -->
    <versionUpgrade :updateExe.sync="updateExe"></versionUpgrade>

    <!-- 个人信息修改 -->
    <edit-info v-show="edit_section_show" @updateInfo="updateInfo" @closeEdit="closeEdit" :Mobile="myMobile"
      :Email="myEmail" :Telephone="myTelephone"></edit-info>
    <!-- 查看文件 -->
    <files-view v-if="files_show" :files_show="files_show" :toInfo="toInfo" @filesViewClose="filesViewClose"
      @toForwarding="toForwarding" @toDownFile="toDownFile"></files-view>
    <!-- 远程 zk15新增ref="remoteControl"-->
    <remote-control v-if="controlViwe_show" @controlClose="controlClose" @setControlType="setControlType"
      @setRemoteType="setRemoteType" :toControlLabel="toControlLabel" :control_type="control_type" :toInfo="toInfo"
      :requestUser="requestUser" :toRegisterid="toRegisterid" :toControlPassword="toControlPassword"
      :myControlPassword="myControlPassword" :remoteState="remoteState" :controlViwe_show="controlViwe_show"
      :remoteType="remoteType" :toControlName="toControlName" ref="remoteControl"></remote-control>
    <!-- 同屏(暂废弃) -->
    <!-- <screen-control
      v-show="screenViwe_show"
      :toInfo="toInfo"
      :isInviter="isInviter"
      :isReceiveShow="isReceiveShow"
      :isConsentShow="isConsentShow"
      :receiveScreenMsg="receiveScreenMsg"
      @screenClose="screenClose"
      @isReceiveShowFn="isReceiveShowFn"
      @isConsentShowFn="isConsentShowFn"
    >
    </screen-control> -->

    <!-- 群消消息个人信息查看 -->
    <mySeePersonal :newsMemberInfo="newsMemberInfo" :newsMemberInfoShow.sync="newsMemberInfoShow"></mySeePersonal>

    <!-- 添加待办 -->
    <myAddProcessing ref="myAddProcessing" :myInfo="myInfo" @getRemind="getRemind" :processedItem="processedItem"
      :sqlTable="sqlTable" :toInfo="toInfo" :remindStatus="remindStatus" :addProcessedShow.sync="addProcessedShow">
    </myAddProcessing>

    <!-- 待办提醒 -->
    <myReminder @toCalendarDetails="toCalendarDetails" @toNoticeDetails="toNoticeDetails" :calendarList="calendarList"
      :noticeList="noticeList"></myReminder>

    <!-- 公告 -->
    <myGroupannouncement @addNoticeClick="addNoticeClick" :my_position="my_position" @delNoticeShow="delNoticeShow"
      @addDownloadList="addDownloadList" :groupNoticeShow.sync="groupNoticeShow" :groupNoticeList="groupNoticeList">
    </myGroupannouncement>

    <!-- 添加群公告 -->
    <myAddgroupannouncement @updateNotice="getGroupPublicNotices" :toInfo="toInfo" :myInfo="myInfo" :addNoticeShow.sync="addNoticeShow">
    </myAddgroupannouncement>

    <!-- 分组管理 -->
    <groupManager :myInfo="myInfo" :curfriendGrouping="curfriendGrouping" @friendItemClick="friendItemClick"
      :friendsGroup="friendsGroup" :managementShow.sync="managementShow"></groupManager>

    <!-- 添加好友分组 -->
    <Modal v-model="userCategoryShow" :title="curfriendGrouping.index == 0 ? '添加好友分组' : '重命名分组'" @on-ok="addUserCategory">
      <i-input v-model="userCategory" placeholder="请输入分组名称"></i-input>
    </Modal>
    <!-- 好友分组菜单 -->
    <div class="friends_edit_menu" v-if="friendsEditShow" :style="{ top: menuTop + 'px', left: menuLeft + 'px' }">
      <ul>
        <li v-for="(item, index) in friendsEditMenu" v-show="!((index == 1 || index == 2) && curfriendGrouping.ID == '1')"
          :key="'f_edit' + index" @click.stop.prevent="friendsEdit(index)">
          {{ item }}
        </li>
      </ul>
    </div>
    <!-- 新建日程 -->

    <newCalendar ref="newCalendar" :newCalendarShow.sync="newCalendarShow" :participant="participant"
      :newCalendarTitle="newCalendarTitle" :currentAgenda="currentAgenda" :form="form" :myInfo="myInfo"
      @calendar_close="calendar_close" @submit="submit" @showContacts="showContacts" @delSchedule="delSchedule"
      @newCalendarClick="newCalendarClick"></newCalendar>

    <!-- 删除群成员 -->
    <deleteGroupMembers ref="deleteGroupMembers" @getGroupAndUsers="getGroupAndUsers" :toInfo="toInfo" :myInfo="myInfo"
      :defaultImg="defaultImg" :group_detail="group_detail" :delMemberView.sync="delMemberView">
    </deleteGroupMembers>

    <!-- 全部语录 -->
    <myQuotations :quotationsTotal="quotationsTotal" :currentPage="currentPage" :defaultImg="defaultImg"
      :my_position="my_position" @delteleQuotation="delteleQuotation" :selectedGroupId.sync="selectedGroupId"
      :quotationsList="quotationsList" :ws="ws" :textGroupList="textGroupList" :allText.sync="allText"
      @dialogClose="dialogClose"></myQuotations>
    <!-- zk新增,暂未使用远程无人值守 -->
    <!-- <book-tp
    :type="13"
    v-show="bookList[4].show && siderArray[1].active"
    >
      <remote-group
      :getDefaultRemoteArr="getDefaultRemoteArr"
      @addMember="addRemoteMember"
      ></remote-group>
    </book-tp> -->
    <!-- S 服务号 -->
    <serviceNumber :myInfo="myInfo" :isShowService.sync="isShowService"></serviceNumber>
    <!-- E 服务号 -->
  </div>
</template>

<script>
// import utilJs from "@/assets/util";

// import modalView from './publicModal.vue' //群通用模板
// import remoteGroup from "./template/remote_member.vue";//zk129新增，远程人员组件显示
import { Notification } from "element-ui";
import tools from "@/utils/tools";
import newVersionTip from "./dialog/newVersionTip.vue";
import EquipmentInformation from "./dialog/EquipmentInformation.vue";
import mySelectDelOrCol from "./template/my_selectDelOrCol.vue";
import myBroadcastnotification from "./template/my_broadcastnotification.vue";
import detectUpgrade from "./dialog/detectUpgrade.vue";
import mySeePersonal from "./template/my_seePersonal.vue";
import myReminder from "./template/my_reminder.vue";
import myAddProcessing from "./template/my_addProcessing.vue";
import deleteGroupMembers from "./template/deleteGroupMembers.vue";
import versionUpgrade from "./dialog/versionUpgrade.vue";
import serviceNumber from "./dialog/serviceNumber.vue";
import myAddgroupannouncement from "./template/my-addgroupannouncement.vue";
import myGroupannouncement from "./template/my_groupannouncement.vue";
import groupManager from "./dialog/groupManager.vue";
import myQuotations from "./dialog/my_quotations.vue";
import modlaFirst from "./dialog/modlaFirst.vue";
import newCalendar from "./template/newCalendar.vue";
import myCurriculum from "./template/my_curriculum.vue";
import myArticle from "./template/my_article.vue";
import searchRecord from "./template/search_person_record.vue"; //zk120新增，点击某一条聊天记录展示的当前人员聊天记录
import filesExamine from "./template/files_examine.vue"; //文件预览
import filesView from "./template/files_view.vue"; //查看文件
import broadDetail from "./template/broad_detail.vue"; //广播详情
import updateAvatar from "./template/update_avatar.vue"; //更新头像
import editInfo from "./template/edit_info.vue"; //修改个人信息
import mapView from "./template/map_view.vue"; //地图显示组件
import bookTp from "./template/address_book_tp.vue"; //通讯录通用模板
import historicalNews from "./template/historical_news.vue"; //查看历史消息
import quotations from "./template/quotations.vue"; // 重点语录
import newsEditor from "./template/news_editor.vue"; //消息内容编辑组件
import readConsult from "./template/read_consult.vue"; //已读未读列表
import chatSettings from "./template/chat_settings.vue"; //聊天设置
import headerParent from "./template/header_parent.vue"; //聊天页头部
import homeChatMain from "./template/home_chat_main.vue"; //主页面聊天
import sessionListSider from "./template/session_list_sider.vue"; //会话列表
import homeSider from "./template/home_sider.vue"; //左侧边栏
import clearItem from "./confirm_view.vue"; //通用确认框
import joinGroup from "./confirm_view.vue"; //确认入群
import noticeDelete from "./confirm_view.vue"; //删除公告
import systemItem from "./system.vue"; //系统设置
import passWord from "./password.vue"; //修改密码
import qrcode from "./template/qrcode.vue"; //二维码组件
import groupQrcode from "./template/qrcode.vue"; //群二维码分享
import memberCard from "./template/member_card.vue"; //对方资料卡
import mMap from "./template/m-map.vue"; //地图
import departmentList from "./template/departmentList.vue"; //我的部门列表组件
import broadSend from "./broadsend.vue"; //广播组件
import broadList from "./template/broad_list.vue"; //广播列表
import articleList from "./template/article_list.vue"; //文章列表
import vueList from "./template/list.vue";
import deleteItem from "./delete.vue";
import mAudio from "./template/audio.vue";
import remoteControl from "./template/remote_control.vue"; // 远程控制显示
import screenControl from "./template/screen_control.vue"; // 同屏控制显示
import MsgRecord from "./messageRecord";
import { VueCropper } from "vue-cropper";
// import GroupImg from "../../static/image/home/groupInfo.png";
import userImg from "../../static/image/home/person_1.png";
import { mapState, mapMutations } from "vuex";
import searchBroad from "./home_comp/search_broad";
import MemberCards from "./home_comp/member_cards.vue"; //综合搜索对方资料卡
import SystemNotice from "./home_comp/systemNotice.vue";
import MyCollection from "./home_comp/MyCollection.vue";
import MyGroups from "./home_comp/myGroups.vue";
import FrequentContacts from "./home_comp/frequentContacts.vue";
import Remote from "./workbench/remote/remote"; //远程控制
import Screen from "./workbench/screen/screen"; //同屏观看
import UnTreeSelect from "./universal/unTreeSelect.vue";
import SearchShow from "./search/index.vue";
import structureMain from "./home_comp/structure.vue";
import offdoc from "./template/offdoc.vue";
import assectToExamine from "./template/assectToExamine.vue";
import assectNewSearch from "./template/assectToExamineComponents/assectNewSearch.vue";
import assectSeachWindow from "./template/assectToExamineComponents/assectSeachWindow.vue";
import { ntalkLogin } from '../api/zizhuji'
import {
  getGroup,
  getUserInfo_axios,
  getUsersStatus,
  findGroup,
  addGroup,
  delGroupPublicNoticesBatch,
  getGroupByUserId,
  delSchedule_axios,
  getSchedule_axios,
  addSchedule,
  getUserCategoryMembers_axios,
  delUserCategory_axios,
  addUserCategory_axios,
  getUserCategoryNames_axios,
  renameUserCategory_axios,
  getGroupPublicNotices_axios,
  delRemind_axios,
  updateIsDone_axios,
  getCollect_axios,
  getRemindAll,
  getFileCatalog_axios,
  getGroupAndUsersById,
  delMember_axios,
  getUserDnd,
  universal_axios,
  addUserCategoryMember,
  delUserCategoryMember,
  getMyDepartments,
  getSetaTopList,
  selectUserTask,
  insertUserTaskLog,
  charRecord,
} from "../api/home";

import { assetsLogin, toExamine } from "../api/assetsWorkApp.js";
//2024.5.23 cq新增，根据既有消息的时间戳对消息重排，防止消息顺序混乱
let currentTempChatTimeMap = {}
export default {
  components: {
    newVersionTip, //  版本升级弹窗dialog
    EquipmentInformation, // 设备信息dialog
    mySelectDelOrCol, //  多选 收藏删除
    myBroadcastnotification, // 广播通知
    detectUpgrade, // 检测版本升级dialog
    mySeePersonal, // 消息个人信息
    myReminder, //   待办提醒
    myAddProcessing, //    添加待办
    deleteGroupMembers, // 删除群成员
    versionUpgrade, // 强制升级dialog
    serviceNumber, // 服务号  dialog
    myAddgroupannouncement, //新增群公告
    myGroupannouncement, // 组公告
    groupManager, // 分组管理dialog
    myQuotations, // 语录  dialog
    modlaFirst, //  转发dialog
    myArticle, //  文章
    myCurriculum, //  日程
    newCalendar, // 新增日程
    structureMain,
    SearchShow,
    UnTreeSelect,
    Screen,
    Remote,
    groupQrcode,
    remoteControl,
    screenControl,
    filesExamine,
    filesView,
    broadDetail,
    updateAvatar,
    editInfo,
    mapView,
    bookTp,
    historicalNews,
    newsEditor,
    readConsult,
    chatSettings,
    headerParent,
    VueCropper,
    departmentList,
    broadList,
    vueList,
    deleteItem,
    systemItem,
    passWord,
    clearItem,
    joinGroup,
    broadSend,
    mMap,
    mAudio,
    qrcode, //二维码
    memberCard,
    MemberCards,
    homeSider, //左侧边栏
    sessionListSider, //会话列表
    homeChatMain, //聊天主体
    noticeDelete, //公告删除
    articleList, //文章列表
    quotations, // 重点语录
    MsgRecord, // s搜索聊天记录
    // remoteGroup,//zk129新增，无人值守
    searchRecord, //zk120新增
    searchBroad,
    SystemNotice, //入群系统消息
    MyGroups, //我的群组
    MyCollection, //我的收藏
    FrequentContacts, //常用联系人
    offdoc, //公文待办
    assectToExamine, // 资产待办
    assectNewSearch,
    assectSeachWindow,
  },
  //数据data
  inject: ["reload"],
  provide() {
    return {
      reqLoading: this.reqLoading,
    };
  },
  data() {
    return {
      oldOff: [],
      unNoticeArr: {},
      actName: "",
      instanceId: "",
      searchType: 0,
      isAssectSearchShow: false,
      newSearchShow: false,
      assectForm: {},
      assectName: "",
      reqLoading: {
        state: false,
      },
      imgLoading: false,
      newInfo: {},
      shareFileArr: [],
      form: {
        //自定义日程提醒
        schedulerType: "",
        repeatRate: "",
        repeatTimes: "",
      },
      setNum: 0,
      offlineInterval: [3, 5, 10],

      pickerOptions: {
        //指派时间范围限制
        disabledDate: (time) => {
          return time.getTime() < Date.now() - 24 * 3600 * 1000; //如果不包括今天。就是return time.getTime() > Date.now() - 24*3600*1000;
        },
      },

      isShowService: false,
      flags: 0, //判断打开的是公文还是待办
      formMsgs: {}, //打开的公文或待办
      controling: false,
      forwardMsg: "",
      toControlName: "",
      // showTree: false,
      login1: false,
      login2: false,
      broad_detail_show: false,
      sendOffline: "",

      broadNoRead: 0,
      senHot: 0,
      isSearchShow: false,
      isListSider: true,
      deviceInfo: {}, //zk0302新增，设备信息
      deviceInfoShow: false, //zk0220新增，是否显示设备信息
      showNewVersion: false, //zk129新增，是否显示更新信息
      newVersionDetail: null, //zk129新增，最新版本信息，若跟当前版本不一致则提示更新

      // optionsBroadValue: "时间排序",
      searchTargetShow: false,
      searchviewTarget: null,
      recordId: "", //zk120新增，当前点击的哪一条记录，用于定位
      recordList: [], //zk120新增，获取聊天记录
      recordshow: false, //zk120,是否展示聊天记录
      searchStartTime: "", //zk120
      searchEndTime: "", //zk120
      timeShow: false, //zk120是否展示时区
      newSearch: "", //zk119新增，再查询key值
      searchInputShow: false, //zk119新增，输入框的显隐
      detailArray: {}, //zk119新增，存放详情信息,根据词条该表
      staticArray: {}, //zk119新增，原始数据，不会改变，参照用
      searchArray: [], //zk119新增，存放关键字
      detailShow: false, //zk118新增，是否显示搜索详情
      firstFrame: [], //zk14新增，存放聊天记录第一屏的chatlist1，用来解决无限循环
      issearching: false, //zk1228新增，当前是否在搜索
      workIndex: 0, //zk1225新增，当前激活的是哪个worklist
      oldSession: [], //zk1223新增，专门存放sessionlist的旧值
      currentRemoteGroup: "", //zk129新增，哪个远程分组要添加成员
      containArr: [], //zk新增，这是包含了指定id的消息的chatlist，搜索定位使用
      broad_show_item_index: null,
      isResetFiles: null,
      newCalendarShow: null,
      treeList: null,
      remindSearch: null,
      remindOfficialTime: "",
      remindOfficialTimeDispose: "",
      officialManageTotal: 0, //公文未处理的总数
      screenWidth: 0,
      screenHeight: 0,
      isDepartmentShow: false,
      chatMsgPage: 0, //新增聊天分页
      chatMsgPageSize: 20, //新增聊天分页
      chatMsgTotal: null, //新增聊天消息总数
      delId: null, //新增删除群语录的当前id
      isEditor: false, //新增是否编辑
      readNumber: 10, //每次次翻页刷新几条，整体显示数目为该数字的两倍
      currentNewsId: null, //zk新增，当前点击的历史消息的id
      havePre: true, //zk新增，是否还能往前查找
      havenext: false, //zk新增，是否还能往后查找
      currentTempChat: [
        [], //pre
        [], //current
      ], //zk新增，当前窗口内容暂存,0用来存新发的消息，1用来存历史消息
      showDownloadData: false, //zk新增，是否显示下载情况选项卡
      currentItem: null, //zk新增，当前消息的已读未读，已下载未下载等信息
      activeIndex: "0", //zk新增，readConsult激活项
      onceCheckArray: [], //zk新增，当前转发选中的人员
      flagHeadType: 0, //新增标记头像加载区域
      toInfoHeadPath: "", //新增单人会话头像字段
      userImg,
      // GroupImg,
      // filesCount:[],//收藏列表
      files_cur: 1, //文件当前页数
      pageSize: 10, //每页显示条数
      page_num: 1, //分页
      toControlLabel: 2,
      isScreenshot: {},
      isOndropHandle: false, //文件是否在拖拽生成中,防止生成图标中切换会话
      updateFileList: [], //文件上传列表，引用传递方式更新文件进度
      clipBoardFile: {}, //粘贴板文件
      noticeConfirm: false,
      isForwardMore: false,
      shareGroupInfo: {},
      showJoinGroup: false, //入群提示
      shareInfo: {},
      fileHistory: [], //共享文件历史记录
      copyShow: false,
      leaveTimeInterval: "",
      // memberSelList: [], //已选人员列表
      // searchMemberList: [], //群成员搜索(删除)
      // searchMember: "", //群成员搜索内容
      delMemberView: false,
      chatFunctionActive: false,
      chatChooseList: [], //聊天内容多选
      isMultiSelect: false,
      calendarList: [], //日程提醒
      newCalendarTitle: 1, //新建日程标题
      currentAgenda: {}, //当前日程
      scheduleList: [],
      newScheduleList: [], // 新增过滤后的日程数组
      participant: [],

      scheduleText: "", //日程内容
      scheduleAddress: "", //日程地址
      currentDayIndex: 0, //选择日期下标
      programmeTimeList: [], //我的日程24小时数组
      currentDay: 1,
      currentMonth: 1,
      currentYear: 1970,
      currentWeek: 1,
      days: [],
      curfriendGrouping: {
        index: 0,
        USER: [],
      },
      friendsEditShow: false, //好友管理菜单
      menuLeft: 0,
      menuTop: 0,
      friendsEditMenu: ["添加分组", "重命名", "删除该组", "分组管理器"],
      friendsGroup: [], //好友分组默认组
      userCategoryShow: false,
      userCategory: "",
      managementShow: false,
      addNoticeShow: false,
      groupNoticeList: [], //群公告
      groupNoticeShow: false, //群公告显示
      noticeList: [],
      remindStatus: 0,
      processedTypeSel: "0", //待办类型选择
      processedTypeSelAdd: "0", //待办状态选择
      remindList: [], //待办列表
      dataList: [], //已完成列表
      notDataList: [], //未完成列表
      remindOfficialList: [], //合并公文后的待办列表
      remindOfficialListArr: [], //合并公文后的待办列表
      downLoadFileList: [], //公文附件列表
      isOpenOfficial: false,
      offItem: null,
      // processedTime: "",
      timeOpen: false,
      addProcessedShow: false,
      processedItem: {}, //待办单条数据
      newsMemberInfo: {}, //系统消息成员信息
      newsMemberInfoShow: false, //系统消息成员显示
      groupCodeShow: false,
      groupNews: [], //系统消息
      auditNotice: [], //审核通知
      systemTab: 0,
      systemShow: false,
      tabList: [], //共享文件导航
      curren_tab: 0, //共享文件当前下标
      fileCatalogList: [],
      playerOptions: {},
      remoteType: 0, //控制类型1 发起控制 2被控制
      remoteState: 0,
      requestUser: {}, //请求人信息
      // myRegisterid:'',//我的注册码
      toRegisterid: "", //对方注册码
      myControlPassword: "", //我的注册秘密
      toControlPassword: "", //对方注册秘密
      controlViwe_show: false, //远程控制显示隐藏
      screenViwe_show: false, //同屏控制显示隐藏
      receiveScreenMsg: null, //被邀请接收到的参数
      isInviter: false, //是否是邀请人
      isReceiveShow: false, //邀请人
      isConsentShow: false, //被邀请人
      isAutoOpenScreen: false, //是否自动打开同屏设置
      control_type: 0, //远程控制类型
      control_show: false, //远程控制选择

      isSendFile: false, //文件是否上传中
      files_show: false, //查看文件显示隐藏
      fullState: 0,
      contentReset: 0,
      personCount: 0,
      personalStatus: 0,
      edit_section_show: false, //修改个人信息
      datepickerOptions: {
        disabledDate(date) {
          return date && date.valueOf() < Date.now() - 86400000;
        },
      },
      quickShow: false, //快捷回复显示隐藏
      config_active: false, //配置显示隐藏
      configList: [
        {
          title: "系统设置",
          url: "static/image/home/system_set.png",
        },
        {
          title: "修改密码",
          url: "static/image/home/system_password.png",
        },
        // {
        //   title: "版本升级",
        //   url: "static/image/home/updateExe/set_update.png",
        // },
        {
          title: "清理缓存",
          url: "static/image/home/system_del.png",
        },
        // {
        // 	title:'手机版本',
        // 	url:'static/image/home/system_phone.png'
        // },
        {
          title: "退出登录",
          url: "static/image/home/system_logout.png",
        },
      ],
      myMobile: "",
      myEmail: "",
      myTelephone: "",
      forwardingList: [], //转发文件集合
      cropper_show: false,
      broadOfflineCount: [],
      editActive: true,
      editGroupName: "",
      reconnect: false, //是否重连
      toinfoSession: {},
      viewTargetShow: false,
      downloadList: [],
      mapData: null,
      timeInit: "",
      activeRecords: false, //历史消息记录开关
      record_count: 40, //历史消息显示条数
      activeWindowState: true,
      deleteIcon: false,
      unreadMuster: [], //未激活窗口未读列表
      firstTip: true,
      defaultImg: 'this.src="static/image/home/person_1.png"',
      errorImg: 'this.src="static/image/home/document.png"',
      // options:{'url':'data-source'},
      group_read: 0,
      group_unread: 0,
      readUsers: [],
      unreadUsers: [],
      read_info_show: false, //群已读未读显示隐藏
      start_time: null, //消息搜索开始时间
      end_time: null, //消息搜索结束时间
      flagTime: true, //显示隐藏撤销按钮
      chatSearchList: [], //消息搜索匹配集合
      chatSearch: "", //消息搜索内容
      personal_chat_list: false,
      viewTargetInfo: true, //是否显示个人信息
      viewNum: 100, //群成员查看数量
      editorOption: {
        placeholder: "",
      },
      content: "",
      ifCopy: false,
      show_index: 11,
      work: null,
      free_list: [], //免打扰列表
      checkLastArray: [], //最近联系人选择列表
      forwarding_array: null, //转发内容
      cur_state: "",
      state_sure: false,
      state_show: false, //显示隐藏工作状态
      state_input_value: "", //工作状态���容
      show_map: false, //
      my_position: 3, //我的群聊权限
      broad_show_item: null,
      article_show_item: null,
      forwarding_list: [],
      forwarding_show: false,
      reply: null,
      specifield_istrue: false,
      specified_show: false, //@显示
      isRegDel: false,
      userValue: "", //输入框内容
      group_detail: {
        users: [],
      }, //群详细
      group_info: {},
      group_people: [], //群人数
      group_info_show: false, //群信息展示
      topChat: false, //置顶聊天
      messageFree: false, //免打扰
      // userInputKey: new Date().getTime(),
      tabs_cur_name: -1,
      toInfoTop: 0,
      toInfoLeft: 0,
      toRemark: "",
      viewTarget: null,
      isHaveOffline: false,
      broadKey: new Date().getTime(),
      broadSendList: [], //发送广播对象列表
      articleSendList: [], //发送文章对象列表
      screenPersonList: [], //同屏邀请对象列表
      oldScreenPersonList: [], //上一次同屏邀请对象列表
      globalOverScreen: false,
      isUpdateUser: false,
      screenFlag: null, //同屏参数
      chatList: [[], []],
      chatFunArray: [
        {
          name: "add",
          active: false,
          title: "添加联系人",
        },
        //  {
        // 	name: 'history',
        // 	active: false,
        // 	title: '历史记录'
        // },
        {
          name: "detail",
          active: false,
          title: "个人简介",
        },
      ], //聊天页面头部功能
      broadSendShow: false,
      groupList: [], //用户群列表
      groupListShow: null,
      searchTime: null, //搜索定时

      searchHave: true,
      searchResultShow: false, //是否显示搜索结果栏
      broadList: [],
      pageBroadList: [],
      articleList: [],
      articleMsg: null,
      friendShow: false, //常用联系人状态
      broadShow: false, //广播列表状态
      fullWindow: false, //全屏状态
      // chating: false,//zk注释，当前人员的聊天激活状态，不应只在当前页面维护，存到vuex
      clearStatus: false, //清理缓存项状态
      passwordStatus: false, //修改密码项状态
      windowStatus: false, //系统设置项状态
      deleteContent: "你确定要永久删除吗?",
      deleteShow: false, //文件删除功能状态
      fileList: [], //文件列表
      myCardShow: false, //个人信息状态
      modalSearchValue: "", //创建聊天搜索值

      modalTitle: 0, //modal标题

      modalNameValue: "", //创建聊天名字
      modalFirst: false, //创建聊天状态
      modalCheckArray: {
        show: false,
      }, //modal已选择数组
      checkPersonArray: [], //已选择常用联系人人员数组
      modalSecond: false,
      sessionList: [], //会话列表
      currentStructureList: [], //当前组织架构列表
      currentStructureName: [], //当前组织架构名字
      currentStructureIndex: 0, //当前选择的组织架构下标
      currentCheckItem: [], //会话列表当前操作项

      offsetTop: 0, //功能表位置上
      offsetLeft: 0, //功能表位置左
      minorShow: false, //功能表状态
      friendsList: [], //常用联系人列表
      setaList: {}, //置顶列表
      ifLinkman: false, //是否是常用联系人
      isDissolve: false, //当前群聊是否解散，zk111标识，当前是否在群（false在，true不在）
      toInfo: {
        id: "",
        name: "",
        isGroup: false,
        status: "",
      },
      status: null,
      modalFirstList: [
        {
          id: 5,
          title: "最近联系人",
          url: "static/image/home/contact/contact.png",
          show: true,
        },
        {
          id: 4,
          title: "常用联系人",
          url: "static/image/home/contact/favorite_contacts.png",
          show: true,
        },
        {
          id: 3,
          title: "组织架构",
          url: "static/image/home/contact/structure.png",
          show: true,
          structureShow: false,
          structureList: [],
        },
        {
          id: 6,
          title: "我的群组",
          url: "static/image/home/contact/myGroup.png",
          show: true,
        },
        {
          id: 7,
          title: "文件传输助手",
          url: "static/image/word/app_transfer.png",
          show: true,
        },
      ], //创建聊天右侧
      workList: [
        {
          id: 1,
          title: "发布广播",
          url: "static/image/home/contact/sendBroad.png",
          show: false,
        },
        {
          id: 2,
          title: "广播通知",
          url: "static/image/home/chat/broadimg.png",
          show: false,
        },
        {
          id: 3,
          title: "收发文件",
          url: "static/image/home/contact/file_state.png",
          show: false,
        },
        {
          id: 4,
          title: "共享文件",
          url: "static/image/home/contact/share_file.png",
          show: false,
        },
        {
          id: 5,
          title: "我的收藏",
          url: "static/image/home/contact/collection_big.png",
          show: false,
        },
        {
          id: 6,
          title: "我的待办",
          url: "static/image/home/contact/need_big.png",
          show: false,
        },
        {
          id: 7,
          title: "我的日程",
          url: "static/image/home/contact/schedule_big.png",
          show: false,
        },
        {
          id: 8,
          title: "我的文章",
          url: "static/image/home/article/my_article.png",
          show: false,
        },
        {
          id: 9,
          title: "公文管理",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 10,
          title: "远程控制",
          url: "static/image/home/article/my_article.png",
          show: false,
        },
        {
          id: 11,
          title: "同屏观看",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 12,
          title: "文件传输助手",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 13,
          title: "资产申请",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 14,
          title: "固定资产申购流程",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 15,
          title: "采购确认流程",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 16,
          title: "调拨流程",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 17,
          title: "报废流程",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 18,
          title: "补货申请流程",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 19,
          title: "退货流程",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 20,
          title: "低值易耗申购流程",
          url: "static/image/home/contact/official.png",
          show: false,
        },
        {
          id: 21,
          title: "低值易耗申领流程",
          url: "static/image/home/contact/official.png",
          show: false,
        },
      ],
      bookList: [
        {
          id: 4,
          title: "常用联系人",
          url: "static/image/home/contact/favorite_contacts.png",
          show: false,
        },
        {
          id: 2,
          title: "我的群组",
          url: "static/image/home/contact/myGroup.png",
          show: false,
        },
        {
          id: 3,
          title: "组织架构",
          url: "static/image/home/contact/structure.png",
          show: false,
          structureShow: false,
          structureList: [],
        },
        {
          id: 5,
          title: "我的部门",
          url: "static/image/home/contact/department_icon.png",
          myDepartment: [],
          show: false,
        },
        // {//zk新增，无人值守暂未使用
        //   id: 6,
        //   title: "无人值守",
        //   url: "static/image/home/contact/department_icon.png",
        //   myDepartment: [],
        //   show: false,
        // },
      ], //通讯录列表
      commonList: [
        {
          id: 1,
          title: "",
          url: "static/image/home/contact/sendBroad.png",
          show: false,
        },
      ],
      siderArray: [
        {
          title: "会话",
          url: "static/image/home/btn_news_nor.png",
          src: "static/image/home/btn_news_sel.png",
          active: true,
        },
        {
          title: "通讯录",
          url: "static/image/home/sider/menu_contacts_default.png",
          src: "static/image/home/sider/menu_contacts.png",
          active: false,
        },
        {
          title: "办公事务",
          url: "static/image/home/work_icon.png",
          src: "static/image/home/work_sel_icon.png",
          active: false,
        },
        {
          title: "工作台",
          url: "static/image/screen/menu_app_default.png",
          src: "static/image/screen/menu_app.png",
          active: false,
        },
      ], //侧边栏列表
      myDepartment: [],
      audio_play: null, //语音播放的refs
      audio_item: null, //语音播放的messageId
      audio_time: null, //语音播放时图片更改定时器
      expression: [
        [
          "微笑",
          "撇嘴",
          "色",
          "发呆",
          "得意",
          "流泪",
          "害羞",
          "闭嘴",
          "睡",
          "大哭",
          "尴尬",
          "发怒",
          "调皮",
          "呲牙",
          "惊讶",
          "难过",
          "酷",
          "冷汗",
          "抓狂",
          "吐",
          "偷笑",
          "可爱",
          "白眼",
          "傲慢",
          "饥饿",
          "困",
          "惊恐",
          "流汗",
          "憨笑",
          "大兵",
          "奋斗",
          "咒骂",
          "疑问",
          "嘘",
          "晕",
          "折磨",
        ],
        [
          "衰",
          "骷髅",
          "敲打",
          "再见",
          "擦汗",
          "抠鼻",
          "鼓掌",
          "糗大了",
          "坏笑",
          "左哼哼",
          "右哼哼",
          "哈欠",
          "鄙视",
          "委屈",
          "快哭了",
          "阴险",
          "亲亲",
          "吓",
          "可怜",
          "菜刀",
          "西瓜",
          "啤酒",
          "篮球",
          "乒乓",
          "咖啡",
          "饭",
          "猪头",
          "玫瑰",
          "凋谢",
          "示爱",
          "爱心",
          "心碎",
          "蛋糕",
          "闪电",
          "炸弹",
          "刀",
        ],
        [
          "足球",
          "瓢虫",
          "便便",
          "月亮",
          "太阳",
          "礼物",
          "拥抱",
          "强",
          "弱",
          "握手",
          "胜利",
          "抱拳",
          "勾引",
          "拳头",
          "差劲",
          "爱你",
          "否定",
          "确认",
          "爱情",
          "飞吻",
          "跳跳",
          "发抖",
          "怄火",
          "转圈",
          "磕头",
          "回头",
          "跳绳",
          "挥手",
          "激动",
          "街舞",
          "献吻",
          "左太极",
          "右太极",
        ],
      ], //表情列表
      weekKV: {
        1: "一",
        2: "二",
        3: "三",
        4: "四",
        5: "五",
        6: "六",
        7: "日",
      },
      faceShow: false,
      offline_arr: [],
      message_update: true,
      appString: "http://172.16.66.30:101/1.jpg",
      appShow: false,
      downloadHistoryList: [],
      option: {
        img: "",
        outputSize: 1, //剪切后的图片质量（0.1-1）
        full: false, //输出原图比例截图 props名full
        outputType: "png",
        canMove: true,
        original: false,
        canMoveBox: true,
        autoCrop: true,
        autoCropWidth: 200,
        autoCropHeight: 200,
        fixedBox: false,
        info: false,
        centerBox: true,
        fixed: true,
      },
      curNotice: {},
      file_arr: [],
      file_length: "",
      // footShow:false,
      timing: false, // 记录时间控件的时分秒是否变化
      clickIntervale: null, // 解决单击双击冲突问题
      pageFlagShow: true, // 强制刷新页面
      broadFlagShow: true, // 强制刷新广播页面
      broadListFlagShow: true, // 强制刷新广播列表页面
      isShare: false, // 新增分享群标记
      shareChoosed: [], // 新增群成员id数组集合
      intervaleARR: [], // 我的待办定时器数组
      scheduleARR: [], // 我的日程定时器数组
      remindStr: "remind", // 初始化我的待办定时器名称字段
      scheduleStr: "schedule", // 初始化我的待办定时器名称字段

      isDisabled: true, // 新增日程是否禁用选择结束重复时间
      broadTotal: 0, // 新增广播列表总条数
      broadSearchValue: "", // 新增广播查询字段
      departmentValue: "", //广播部门筛选
      articleTitleTime: "", // 新增查询标题文章筛选
      article_editor_show: false, // 新增文章编辑显示与隐藏
      historyList: [], // 新增搜索历史列表
      historyFocus: false, // 新增搜索记录显示
      offline_num: 0, // 新增记录未读消息数量
      isMacAddress: true, // 新增判断远程控制是否为同一台电脑
      shareImgList: [], // 新增接收分享图片的数组
      onlyFirst: true, // 新增控制执行次数的变量
      onlyFirstCollect: true, // 新增点击我的收藏只执行一次的变量
      updateExeShow: false, // 新增更新版本弹框
      isUpdateExeShow: false, // 新增更新版本弹框(更新/已更新)
      updateExe: false, // 新增强制更新版本弹框(更新)

      addUserDisabled: false, // 新增禁止组织架构人员点击确定按钮
      searchUserList: [], // 新增全局搜索数组
      orgUserList: [], // 新增组织架构or我的部门数组
      pickerOptionsStart: {
        disabledDate: (time) => {
          if (this.broad_end_time) {
            return (
              time.getTime() >
              new Date(this.broad_end_time).getTime() - 24 * 60 * 60 * 1000
            );
          }
        },
      },
      pickerOptionsEnd: {
        disabledDate: (time) => {
          if (this.broad_start_time) {
            return (
              time.getTime() <
              new Date(this.broad_start_time).getTime() + 24 * 60 * 60 * 1000
            );
          }
        },
      },
      rightShow: false,
      getRightMenuPosition: {
        x: 0,
        y: 0,
      },
      groupInfo: null,
      quotationsShow: false, // 是否显示重点语录
      cornalShow: false, // 语录收起按钮是否显示
      allText: false, // 全部语录弹窗
      textGroupList: [], // 我的群数据列表
      selectedGroupId: "", // 语录弹窗中选中的群ID
      quotationsDate: "", // 过滤语录的日期
      quotationsList: [], // 根据条件查询的语录列表
      allQuotationsList: [], // 所有的语录列表
      quotationsTotal: 0, // 全部语录分页总数
      currentPage: 1, // 全部语录当前页

      allRecords: [], // 所有消息记录
      recordsIsGroup: false, // 当前查询的历史记录是否是群消息
      lastClickTime: "", //zk新增，上一次点击的时间
      editFlag: true, //zk新增，编辑日程按钮是否可用
      toForwardingLocal: {}, //czx新增,转发本地文件
      isToForwardingLocal: false, //czx新增,转发本地文件
      isUpdateCount: 0, //czx新增,上传本地数据库备份
      updateItem: {},
      messageTipsArr: {},
      isDetailItem: false,
      search_broad_show_item: false,
      searchBroadItem: null,
      isSaved: false, //过滤重复消息提醒
      offDocParams: {
        //公文查询参数
        keyword: "",
        startTime: "",
        endTime: "",
        viewStartTime: "",
        viewEndTime: "",
        page: 1,
        limit: 20,
      },
      officialTotalPage: 1,
      offTypeTemp: 0, //拉取离线临时类型保存
      isOnline: true, //网络连接情况
      firstUnreadId: "", //回到首条未读
    };
  },

  //监听watch
  watch: {
    // 监听屏幕高度
    // screenHeight() {
    //   if (this.screenHeight > 660) {
    //     this.isFold = true;
    //     this.isFoldCreated = false;
    //   } else {
    //     this.isFold = false;
    //     this.isFoldCreated = true;
    //   }
    // },
    // 我的待办筛选 类型
    processedTypeSel() {
      this.screenRemind();
    },
    // 我的待办筛选 状态
    processedTypeSelAdd() {
      this.screenRemind();
    },
    currentTempChat: {
      //zk新增，监听当前显示聊天内容的替换
      handler(newValue, oldValue) {
        console.log("currentTempChat更新了",newValue);
        //2024.5.23 cq修改，保存既有消息的时间戳，防止消息顺序混乱
        currentTempChatTimeMap = {}
        newValue.forEach((list) =>{
          list.forEach(item=>{
            // console.log('保存既有消息的时间戳 item',[item])
            currentTempChatTimeMap[item.messageId] = item.time
          })
        })
        // console.log('保存既有消息的时间戳', [currentTempChatTimeMap])
        this.$forceUpdate();
        if(this.$store.state.toReplyTemp){
          this.$store.commit("setToReply", this.$store.state.toReplyTemp)
          this.$store.commit("setToReplyTemp", null)
        }
      },
      deep: true,
    },
    group_detail: {
      //zk新增，监听group_detail变化,如果当前登录人在users里，将this.isDissolve设置为false，即当前聊天可用
      handler(newVal, oldVal) {
        console.log(newVal, "监听group_detail的变化");
        let id = this.myInfo.id;
        if (this.toInfo.isGroup == "1") {
          this.isDissolve = true;
          newVal.users.forEach((item) => {
            if (item["ID"] == id) {
              this.isDissolve = false;
            }
          });
        } else {
          this.isDissolve = false;
        }
      },
      deep: true,
    },
    sessionList: {
      //zk新增，监听sessionList变化
      handler(newVal, oldVal) {
        //console.log(newVal,this.oldSession)
        //zk1223修改，监听sessionlist变化是新旧对比进行头像的下载及状态的更新
        let idArr = []; //存放id，用于获取人员在线状态
        let userArr = []; //存放人员完整信息，用
        for (let i in newVal) {
          let flag = false;
          let id1 = newVal[i].id || newVal[i]["ID"];
          for (let j in this.oldSession) {
            let id2 = this.oldSession[j].id || this.oldSession[j]["ID"];
            if (id1 == id2) {
              flag = true;
            }
          }
          if (!flag && newVal[i].isGroup != "1") {
            idArr.push(id1);
            userArr.push(newVal[i]);
          }
        }
        // console.log(idArr, "sessionlist新增人员",oldVal);
        if (oldVal.length !== 0) {
          idArr.forEach((i) => {
            //获取新增状态
            this.updateSessionListStatus(i);
          });
        }
        for (let i in userArr) {
          //zk注释，针对转发头像问题
          this.downLoadHeadPath(userArr[i]);
        }
        let ids = idArr.join(",");
        if (idArr.length > 0) {
          //zk124修改，只获取不在sessionlist的人的在线状态
          // this.$ajax(
          //   "/user/getUsersStatus.do",
          //   { ids: ids },
          //   (data) => {
          //     //获取转发人员的在线状态
          //     if (data.result == "200") {
          //       console.log(data, "查询返回");
          //       for (let i in newVal) {
          //         let id3 = newVal[i].id || newVal[i]["ID"];
          //         for (let j in data.data) {
          //           if (id3 == data.data[j].id) {
          //             this.$set(newVal[i], "status", data.data[j].status);
          //           }
          //         }
          //       }
          //     }
          //   },
          //   (err) => {}
          // );
        }
        this.oldSession = [...newVal];
      },
      deep: true,
    },
    currentItem(newVal) {
      //zk新增，监听currentItem变化,不是file则不显示下载情况
      if (newVal.type == "file") {
        this.showDownloadData = true;
      } else {
        this.showDownloadData = false;
      }
    },
    page_num() {
      // 新增广播/我的收藏/文章分页
      // if (this.workList[1].show) this.getPageNum(this.broadTotal);

      // else
      if (this.workList[4].show) this.getPageNum(this.collectTotal);
      // else if (this.workList[7].show) this.getPageNum(this.articleTotal);
    },

    broad_show_item() {
      if (!this.broad_detail_show) {
        this.broad_detail_show = true;
      }
      // if (this.broad_show_item == null) this.initPage();
    },

    article_show_item() {
      if (this.article_show_item == null) this.initPage();
    },
    // 我的收藏
    typeSel() {
      this.initPage();
    },

    //发送激活状态下未读列表
    activeWindowState() {
      if (this.activeWindowState) {
        if (this.chating) {
          // this.getMessageRecord();//zk1224
          this.updateIsRead(this.toInfo.id, this.toInfo.isGroup); //zk注释，未读变已读
          this.$set(this.toinfoSession, "noRead", 0);
        }
        this.delCurMessageTips(this.toInfo.id);
        console.log("激活状态下未读列表:", this.unreadMuster);
        if (this.unreadMuster.length > 0) {
          // let res = this.$shell("GetInfoUserId", [this.toInfo.id]);
          for (let i = 0; i < this.unreadMuster.length; i++) {
            if (this.toInfo.isGroup == "1") {
              this.ws.send(
                this.$publicSend(
                  this.unreadMuster[i].keys,
                  "1.500",
                  "1.1.2005",
                  {
                    sendUserId: this.unreadMuster[i].sendUserId,
                    receiveUserId: this.myInfo.id,
                    groupId: this.toInfo.id,
                  }
                )
              );
              if (i == this.unreadMuster.length - 1) {
                this.unreadMuster = [];
              }
            } else {
              if (this.chating) {
                //zk新增判断当前聊天框是否激活，激活状态才向服务器端发送已读
                console.log("消息已读确认", this.unreadMuster);
                this.ws.send(
                  this.$publicSend(
                    this.unreadMuster[i].keys,
                    "1.500",
                    "1.1.1014",
                    {
                      sendUserId: this.toInfo.id,
                      receiveUserId: this.myInfo.id,
                      timestamp: new Date().getTime(),
                      isServiceAcc: this.myInfo.authCustservice,
                    }
                  )
                );
                // this.unreadMuster = [];
                //2022/5/27 zc修改 每次将私聊中所有未读改已读的都发送socket
                if (i == this.unreadMuster.length - 1) {
                  this.unreadMuster = [];
                }
              }
            }
          }
        }
      }
    },
    chatSearch() {
      this.$nextTick(() => {
        if (this.chatSearch == "") {
          this.searchChat();
        } else {
          this.searchChat(this.chatSearch);
        }
      });
    },
    // 获取离线列表，zk128标识，sessionlist从此处写入本地数据库this.offline_arr
    offline_arr() {
      console.log(this.offline_arr, 2906);
      let max = this.sessionList.length;
      if (max == 0) {
        //zk16标识，从数据库取到的sessionlist为空，则直接用离线收到的消息替换
        this.sessionList = JSON.parse(JSON.stringify(this.offline_arr));
        this.sortSessionList();
      } else {
        console.log(this.sessionList, "获取离线列表", this.offline_arr);
        //zk16标识，不为空，做拼接
        for (let i = 0, len = this.offline_arr.length; i < len; i++) {
          let a = this.offline_arr[i];
          let isHas = false;
          for (let j = 0, lens = this.sessionList.length; j < lens; j++) {
            let item = this.sessionList[j];
            // if ((item.name == "" || !item.name) && !item.systemId) {//zk16标识name为空且不为系统消息，删除（错误数据？）
            if (this.$isNull(item.name) && !item.systemId) {
              //zk16标识name为空且不为系统消息，删除（错误数据？）
              tools.operationalDatabase(
                `DELETE FROM ${this.sqlTable.sessionList} WHERE userId='${item.id}'`
              );
              this.sessionList.splice(j, 1); //zk16注释
            }
            if ((item.systemId || item.id) == a.userId) {
              this.sessionList[j].type = ""; //先置空原来属性，以防列表会话的消息不是会话内容里的信息最后一条
              if ((item.status === "1" || !item.status) && !item.offline) {
                console.log('累加')
                a.noRead += item.noRead;
              }
              Object.assign(this.sessionList[j], a);
              isHas = true;
            } else if (j == lens - 1 && !isHas) {
              //zk16标识，离线消息循环完毕
              if (a.isGroup != "1") {
                //zk16标识，非群的时候获取用户信息
                this.getUserInfo(
                  a.userId,
                  (res) => {
                    if (res.result == 200) {
                      if (res.data.head) {
                        a.head = res.data.head;
                      }
                      this.sessionList.push(JSON.parse(JSON.stringify(a)));
                    } else {
                      this.sessionList.push(JSON.parse(JSON.stringify(a)));
                    }
                    this.sortSessionList();
                  },
                  (res) => {
                    this.sessionList.push(JSON.parse(JSON.stringify(a)));
                    this.sortSessionList();
                  }
                );
              } else {
                this.sessionList.push(JSON.parse(JSON.stringify(a)));
              }
            }
          }
        }
        this.sortSessionList();
      }
      setTimeout(() => {
        // 新增下载头像
        let headPathList = this.sessionList.filter((item) => item.isGroup == 0);
        headPathList.map((item) => {
          this.downLoadHeadPath(item);
        });
      }, 500);
    },
    state_input_value() {
      this.$forceUpdate();
    },
    toRemark() {
      if (this.viewTarget.remark != this.toRemark)
        this.viewTarget.remark = this.toRemark;
    },
    viewTarget() {
      if (this.viewTarget != null) this.toRemark = this.viewTarget.remark;
    },
    toInfo() {
      this.show_index = 11;
    },

    async receiveInfo() {
      console.log("收到消息内容home=>");
      console.log(this.receiveInfo);
      console.log(JSON.parse(JSON.stringify(this.receiveInfo)));
      let _this = this;
      let head = await this.receiveInfo.head;
      let body = await this.$ws_decode(this.receiveInfo.body);
      let socketInfo = await this.receiveInfo.info;
      // let msgType = this.receiveInfo.head.method == "1.2.1001";
      // let newTable = msgType
      //   ? this.sqlTable.privateList
      //   : this.sqlTable.messageList;

      // let repeatMessage = tools.operationalDatabase(
      //   `SELECT * FROM ${newTable} WHERE messageId='${
      //     this.receiveInfo.head.key
      //   }';`,
      //   1
      // );
      // console.log(repeatMessage, this.receiveInfo.head.key,16511111);

      // 群通知
      if (head.action == "1.900") {
        let isRead = this.toInfo.id == body.groupId ? "1" : "0";
        let cate = head.method;
        // 被邀请方是否为自己
        let isOwn = body.receiveUserId == this.myInfo.id;
        let vArr = JSON.parse(body.content.sections[0].items[0].value);
        let gName = vArr.groupName;
        let rName = vArr.receiveName;
        let rId = vArr.receiveId;
        let sName = vArr.sendName;
        let time = body.content.timestamp;
        //表示被拉进群，放在前面避免进入下一个条件
        if (head.method == "1.1.1001") {
          // 2022/7/19 修改 当被邀请人为自己时更新群
          if (isOwn) {
            this.getGroupUser();
          }
          // 获取groupList并设置是否在该群的状态
          // 2022/7/5 新增进群后更新群人员列表
          this.getGroupAndUsers(this.toInfo.id);
          // zk126新增，建群之后更新session和chat
          let sysValue = this.setSystemGroup(
            body.userId,
            cate,
            rName,
            rId,
            sName,
            gName,
            false
          );
          this.insertData(
            sName,
            body.groupId,
            body.userId,
            "system",
            sysValue,
            time,
            body.messageKey,
            isRead,
            "0",
            "0",
            "0",
            -1,
            "1",
            14,
            6
          );
          this.updateSessionChat(
            body.userId,
            body.groupId,
            sName,
            gName,
            sysValue,
            time,
            "1",
            body.messageKey,
            "system",
            "-1",
            0,
            0,
            ""
          );
        } else if (head.method == "1.1.1002") {
          // 移除群成员
          let sysValue = this.setSystemGroup(
            body.userId,
            cate,
            rName,
            rId,
            sName,
            gName,
            false
          );
          this.insertData(
            sName,
            body.groupId,
            body.userId,
            "system",
            sysValue,
            time,
            body.messageKey,
            isRead,
            "0",
            "0",
            "0",
            -1,
            "1",
            14,
            6
          );
          this.updateSessionChat(
            body.userId,
            body.groupId,
            sName,
            gName,
            sysValue,
            time,
            "1",
            body.messageKey,
            "system",
            "-1",
            0,
            0,
            ""
          );
        } else if (
          rName != "" ||
          head.method == "1.1.1003" ||
          head.method == "1.1.1004"
        ) {
          //zk111标注，1003解散群，1004转移群主
          let sysValue = this.setSystemGroup(
            body.userId,
            cate,
            rName,
            rId,
            sName,
            gName,
            false
          );
          if (head.method == "1.1.1004") {
            time = new Date().getTime();
            // sysValue=`${sName}已将群主转移给您`;message
            sysValue = vArr.text.replace(/\[|\]/g, "");
          }
          this.insertData(
            sName,
            body.groupId,
            body.userId,
            "system",
            sysValue,
            time,
            body.messageKey,
            isRead,
            "0",
            "0",
            "0",
            -1,
            "1",
            14,
            6
          );
          this.updateSessionChat(
            body.userId,
            body.groupId,
            sName,
            gName,
            sysValue,
            time,
            "1",
            body.messageKey,
            "system",
            "-1",
            0,
            0,
            ""
          );
        } else if (head.method == "1.1.1005") {
          //群公告
          this.insertData(
            sName,
            body.groupId,
            body.userId,
            "announcement",
            body.value,
            body.timestamp,
            body.messageKey,
            isRead,
            "0",
            body.attachname,
            body.attach,
            body.attachsize,
            "1",
            body.attachname,
            6
          );
          this.updateSessionChat(
            body.userId,
            body.groupId,
            sName,
            gName,
            body.value,
            body.timestamp,
            "1",
            body.messageKey,
            "announcement",
            body.attachsize,
            body.attachname,
            body.attach,
            "",
            body.attachname
          );
        }
      }
      // 更新个人状态
      if (head.action == "1.101") {
        if (head.method == "1.2.0008") {
          this.refStatus(body);
        }
      }
      //申请入群通知-=
      if (head.action == "1.001") {
        if (head.method == "1.2.0017") {
          //申请入群通知
          this.insertSystemData(body, head);
        } else if (head.method == "1.2.0018") {
          this.insertNoticeData(body);
        } else if (head.method == "1.2.0020") {
          this.updateSystemData(body, head);
        } else if (head.method == "1.2.0010") {
          let noticeData = body.data;
          if (noticeData.file_type == "text") {
            noticeData.value = this.toExpression(
              this.$utilJs.regUrl(noticeData.value)
            );
          }
          // this.noticeList.push(noticeData);
        } else if (head.method == "1.2.0011") {
          // 日程提醒
          let calendar = body.data;
          let calendarData = this.$utilJs.upperJSONKey(calendar);
          this.calendarList.push(calendarData);
        } else if (head.method == "1.2.0013") {
          // 获得置顶列表
          this.getSetaTop();
        } else if (head.method == "1.2.0014" || head.method == "1.2.0114") {
          console.log("日程提醒推送ws");
          this.getSchedule();
        } else if (head.method == "1.2.0015") {
          // 收到其他端消息免打扰推送
          let msg = body.dataUser.data;
          for (let item of msg) {
            item.userId = item.OBJECTID;
          }
          this.free_list = msg;
          this.messageFree = this.free_icon_sign(this.toInfo.id);
          this.$forceUpdate();
        }
      }
      // 修改群信息
      if (head.action == "1.201" && head.method == "1.2.0009") {
        let groupInfo = body.group || {};
        if (groupInfo.id == this.toInfo.id) {
          this.toInfo.name = groupInfo.name;
          this.getGroupDetail(groupInfo.id, true);
        } else {
          this.getGroupDetail(groupInfo.id, false);
        }
        for (let i = 0; i < this.sessionList.length; i++) {
          if (this.sessionList[i].id == groupInfo.id) {
            this.sessionList[i].name = groupInfo.name;
          }
        }
      }

      if (head.action == "1.500") {
        // 读取离线消息
        if (head.method == "1.3.1001") {
          console.log("1.3.1001,离线上线消息", head.method, body);
          // 离线上线 接收离线消息数
          window.sendOffline && clearInterval(window.sendOffline);
          if (body.content) {
            let item = body.content.sections[0].items;
            let arr = [];
            let scheduleList = [];
            let disposalList = [];
            let item1 = JSON.parse(JSON.stringify(item));

            for (let i = 0; i < item1.length; i++) {
              console.log("循环几次里面");
              //   0427  离线消息重复提醒
              let a = item1[i];
              if(!a.lastMsg) continue
              let searchTable =
                a.type == "1"
                  ? this.sqlTable.privateList
                  : this.sqlTable.messageList;
              let msgIsRead = tools.operationalDatabase(
                `SELECT * FROM ${searchTable} WHERE messageId = '${a.lastMsg.messageId}';`,
                1
              );

              if (msgIsRead.list.length > 0) {

                console.log("消息重复", a.lastMsg.messageId);
                continue;
              }
              console.log("继续", a.lastMsg.messageId);
              if (
                a.lastMsg.messageId == "4e9d6fae-7dd6-4d26-a126-64b4183ae237"
              ) {
                console.log("错误消息 4e9d6fae-7dd6-4d26-a126-64b4183ae237");
                continue;
              }
              // 2022/7/18 新增 离线拉取文章信息
              if (a.lastMsg) {
                let b;
                let c;
                if (a.type == "1" || a.type == "2") {
                  try {
                    b = JSON.parse(a.lastMsg.value);
                  } catch (error) {
                    console.log(
                      "解析错误",
                      a.lastMsg.value,
                      a.lastMsg.messageId
                    );
                    continue;
                  }
                  c = a.lastMsg.type;
                  //  0427
                  if (a.sendId == this.toInfo.id) {
                    if (a.type == "1" || a.type == "2") {
                      this.chatList = [[], []];
                      this.getOffline(this.toInfo.id, a.type, 1, "0");
                    }
                  }
                  if (a.sendId != this.myInfo.id) {
                    // 2022/7/11 以下对群公告announcement做额外判断，避免离线最后一条为群公告时不显示
                    let name =
                      a.lastMsg.type == "system" ||
                        a.lastMsg.type == "announcement"
                        ? b.groupName
                        : a.type == "2"
                          ? b.receiveName
                          : b.sendName;
                    let gender = 0;
                    // 1 2 女
                    // 2 1 || 2 2 群
                    // 1 1 男
                    if (a.type == 1 && b.gender == 2) gender = 5;
                    // 女
                    else if (
                      (a.type == 2 && b.gender == 1) ||
                      (a.type == 2 && b.gender == 2) ||
                      b.gender == 0
                    )
                      gender = 1;
                    // 群
                    else if (a.type == 1 && b.gender == 1) gender = 4; // 男

                    arr.push({
                      id: a.sendId,
                      userId: a.sendId,
                      value:
                        c == "GPS"
                          ? "[位置]"
                          : c == "file"
                            ? "[文件]"
                            : c == "audio"
                              ? "[语音]"
                              : c == "image"
                                ? "[图片]"
                                : c == "video"
                                  ? "[视频]"
                                  : c == "shareGroup"
                                    ? "[群分享]"
                                    : c == "screen"
                                      ? "[同屏]"
                                      : c == "announcement"
                                        ? "[群公告]"
                                        : c == "article"
                                          ? "[文章]"
                                          : b.text,
                      time: a.lastMsg.time,
                      gender: b.gender,
                      head: b.head,
                      name: name,
                      isGroup: a.type == "2" ? 1 : 0,
                      noRead: parseInt(a.value),
                      offline: true,
                    });
                    this.messageTips(
                      a.sendId,
                      c,
                      a.lastMsg.type == "announcement"
                        ? "[群公告]"
                        : a.lastMsg.type == "article"
                          ? "[文章]"
                          : b.text,
                      a.type == "1" ? b.head : "",
                      name,
                      a.lastMsg.type == "announcement" ? 1 : gender,
                      a.lastMsg.messageId,
                      parseInt(a.value)
                    );
                  }
                  if (a.lastMsg.type == "article") {
                    this.installArticle(b);
                  }
                } else if (a.type == "3") {
                  // this.insertSystemData(JSON.parse(a.lastMsg.value), head);
                  this.broadOfflineCount.push(a);

                  if (a.lastMsg.messagetype == "9") {
                    //撤回广播
                    this.deleteBroadInit(a.lastMsg.messageId);
                  } else {
                    // this.messageTips(
                    //   "69f175b9-45d3-45e0-87fc-4cbeeff97887",
                    //   "text",
                    //   a.value,
                    //   "",
                    //   "广播通知",
                    //   "3"
                    // );

                    let anum = Number(a.value);
                    this.$set(
                      this.workList[1],
                      "noRead",
                      this.workList[1].noRead
                        ? parseInt(this.workList[1].noRead) + anum
                        : anum
                    );
                  }
                } else if (a.type == "5") {
                  scheduleList.push(a);
                } else if (a.type == "6") {
                  disposalList.push(a);
                } else if (a.type == "7") {
                  console.log(a.lastMsg.value, "分享文章离线推送");
                  // 新增分享文章离线推送
                  // this.installArticle(JSON.parse(a.lastMsg.value));
                }
              }
            }

            // 标识日程读取
            for (let i = 0; i < scheduleList.length; i++) {
              console.log("标识日程读取");
              this.getOffline(scheduleList[i].sendId, "5", 1, "0");
            }
            // 待办读取
            for (let i = 0; i < disposalList.length; i++) {
              this.getOffline(disposalList[i].sendId, "6", 1, "0");
            }

            let same = arr.every((t, i) => {
              return this.oldOff.length == 0 ? false : t.time == this.oldOff[i].time
            })
            if (same && arr.length == this.oldOff.length) {

              console.log('离线消息一样,不更新')

            } else {

              console.log("存离线列表", arr);
              this.offline_arr = arr;
              this.oldOff = JSON.parse(JSON.stringify(arr))
            }
            if (arr.length != 0) {

            }


          }
          // 获取离线广播;
          for (let i = 0; i < this.broadOfflineCount.length; i++) {
            this.getOffline(this.broadOfflineCount[i].sendId, "3", 50, "0");
          }
        }
        else if (head.method == "1.3.1002") {
          console.log("离线消息1.3.1002", body);
          let time2 = Date.now();
          window.sendOffline && clearInterval(window.sendOffline);
          if (body.isEnd != "1") {
            if (body.type == "1" || body.type == "2") {
              //群聊、单聊离线
              let oGroup = body.type == "1" ? "0" : "1";
              let isToJudge = oGroup == "1" ? true : false;
              if (!isToJudge) this.searchAndSaveUser(body.userId);
              let oArr = body.content.sections[0].items;
              let oStr1 = "";
              let oIsDownLoad = 0;
              let oDownLoadId = 1;
              let oDuration = -1;
              let oTime = 0;
              let isTrue = false;
              let rId = oGroup == "1" ? body.userId : body.receiveId;
              let offid = rId == this.myInfo.id ? body.userId : rId;
              // let isServiceAcc = body.isServiceAcc ? 1 : 0 //是否是客服消息
              // if(isServiceAcc){
              //   rId = 10000

              // }
              for (let i = 0, len = oArr.length; i < len; i++) {
                // 新增离线撤销消息更改数据库value值
                this.updateOffData(oArr[i], oGroup);
                let time = body.content.timestamp;
                let sId = oGroup == "1" ? oArr[i].sendId : body.userId;
                let sValue = "";
                //    try {
                //   JSON.parse(oArr[i].value);
                // } catch (error) {
                //   continue;
                // }
                let ist = JSON.parse(oArr[i].value || '{}');
                let fontSize = ist.fontSize || 14;
                let replay = ist.replay ? ist.replay : "";
                let sendName = ist.sendName;
                let aValue = ist;
                let sName = aValue.sendName;
                let rName = aValue.receiveName;
                let gName = aValue.groupName;
                let text = aValue.text;
                let sItem = oArr[i].messagetype;
                // 2022/7/18 新增 离线文章拉取
                if (
                  oArr[i].type == "system" ||
                  oArr[i].type == "text" ||
                  oArr[i].type == "GPS" ||
                  oArr[i].type == "shareGroup" ||
                  oArr[i].type == "revocation" ||
                  oArr[i].type == "announcement"
                ) {
                  if (oArr[i].type == "system") {
                    isTrue = true;
                    sValue = this.setSystemGroup(
                      sId,
                      sItem,
                      rName,
                      rId,
                      sName,
                      aValue.groupName,
                      true,
                      text
                    );
                    // this.updateSessionChat(
                    //   body.userId,
                    //   body.groupId,
                    //   sName,
                    //   gName,
                    //   sValue,
                    //   time,
                    //   "1",
                    //   body.messageKey,
                    //   "system",
                    //   "-1",
                    //   0,
                    //   0,
                    //   ""
                    // );
                  } else if (
                    oArr[i].type == "text" ||
                    oArr[i].type == "GPS" ||
                    oArr[i].type == "revocation"
                  ) {
                    sValue = JSON.parse(oArr[i].value).text;
                    if (oArr[i].type == "GPS") sValue = JSON.stringify(sValue);
                    if (oArr[i].type == "text" || oArr[i].type == "revocation")
                      sValue = sValue.replace(/\'/gi, '"');
                  } else if (oArr[i].type == "announcement") {
                    sValue = JSON.parse(oArr[i].value).value;
                    oIsDownLoad = JSON.parse(oArr[i].value).attachname
                      ? JSON.parse(oArr[i].value).attachname
                      : 0;
                    oDownLoadId = JSON.parse(oArr[i].value).attach
                      ? JSON.parse(oArr[i].value).attach
                      : 1;
                    oDuration = JSON.parse(oArr[i].value).attachsize
                      ? JSON.parse(oArr[i].value).attachsize
                      : -1;
                    sValue = sValue.replace(/\'/gi, '"');
                    console.log(
                      sValue,
                      oIsDownLoad,
                      oDownLoadId,
                      oDuration,
                      "announcement====================="
                    );
                  } else if (oArr[i].type == "shareGroup") {
                    sValue = JSON.parse(oArr[i].value).text;
                    console.log(oArr[i], "离线群分享");
                  }
                  /* oIsDownLoad
                      oDownLoadId */
                  oStr1 += `('${sendName}','${rId}','${sId}','${oArr[i].type}','${sValue}','${oArr[i].time}','${oArr[i].messageId}','0','1','${oIsDownLoad}','${oDownLoadId}',"${oDuration}",'${fontSize}','${replay}'),`;
                  if (oTime < oArr[i].time) oTime = oArr[i].time;
                  //if (isToJudge) this.searchAndSaveUser(sId);
                  if (this.reconnect) {
                    this.updateSessionChat(
                      sId,
                      rId,
                      sName,
                      rName,
                      sValue,
                      oArr[i].time,
                      oGroup,
                      oArr[i].messageId,
                      oArr[i].type,
                      0,
                      0,
                      0
                    );
                  }
                } else if (oArr[i].type == "image") {
                  if (oTime < oArr[i].time) oTime = oArr[i].time;
                  // zk1224修改，downloadmini -> downloadsmall
                  let gpsstr = `('${sendName}','${rId}','${sId}','${oArr[i].type}','','${oArr[i].time}','${oArr[i].messageId}','0','1','${ist.name}',"${ist.id}",'${ist.duration}','${fontSize}','${replay}')`;
                  _this.insertOffData(sId, gpsstr, oGroup, oTime, rId);
                  console.log(gpsstr, 2224);
                  // this.$downLoad(
                  //   "api/v1/oim/image/downloadsmall.do",
                  //   ist.id,
                  //   (wt) => {
                  //     //zk注释，离线图片download->downloadmini
                  //       var fileReader = new FileReader();
                  //       fileReader.onload = function (w) {
                  //         let base64 = w.target.result.replace(
                  //           /^data\:.{1,40}base64\,/gi,
                  //           ""
                  //         );
                  //         let arr = ist.name.split(".").splice(-1)[0];
                  //         let info = _this.$shell("SaveFileStreamczs", [
                  //           _this.myInfo.id,
                  //           ist.id,
                  //           arr,
                  //           base64,
                  //           0
                  //         ]);
                  //         info = JSON.parse(info);
                  //         let gpsstr = `('${sendName}','${rId}','${sId}','${oArr[i].type}','${info.return_msg}','${oArr[i].time}','${oArr[i].messageId}','0','1','${ist.name}',"${ist.id}",'${ist.duration}','${fontSize}','${replay}')`;
                  //         _this.insertOffData(sId, gpsstr, oGroup, oTime,rId);
                  //         _this.findPicId(oArr[i].messageId,info.return_msg)
                  //         if (isToJudge) _this.searchAndSaveUser(sId);
                  //         if (_this.reconnect) {
                  //           _this.updateSessionChat(
                  //             sId,
                  //             rId,
                  //             sName,
                  //             rName,
                  //             info.return_msg,
                  //             oArr[i].time,
                  //             oGroup,
                  //             oArr[i].messageId,
                  //             oArr[i].type,
                  //             ist.duration,
                  //             ist.url,
                  //             ist.id,
                  //           );
                  //         }
                  //       };
                  //       fileReader.readAsDataURL(wt);
                  //   },
                  //   (wt) => {
                  //     console.log("error");
                  //     console.log(wt);
                  //   }
                  // );
                } else if (oArr[i].type == "audio") {
                  const url =
                    this.$store.state.url +
                    "api/v1/oim/file/download.do?id=" +
                    ist.id;
                  oStr1 += `('${sendName}','${rId}','${sId}','${oArr[i].type}','${ist.name}','${oArr[i].time}','${oArr[i].messageId}','0','1','${url}',"${ist.id}",'${ist.duration}','${fontSize}','${replay}'),`;
                  if (oTime < oArr[i].time) oTime = oArr[i].time;
                  if (isToJudge) this.searchAndSaveUser(sId);
                  if (this.reconnect) {
                    this.updateSessionChat(
                      sId,
                      rId,
                      sName,
                      rName,
                      ist.name,
                      oArr[i].time,
                      oGroup,
                      oArr[i].messageId,
                      oArr[i].type,
                      ist.duration,
                      ist.url,
                      ist.id
                    );
                  }
                } else if (oArr[i].type == "video") {
                  this.$Message.success("视频加载中..", 3);
                  this.$downLoad(
                    "api/v1/oim/file/download.do",
                    ist.id,
                    (wt) => {
                      var fileReader = new FileReader();
                      fileReader.onload = function (w) {
                        let base64 = w.target.result.replace(
                          /^data\:.{1,40}base64\,/gi,
                          ""
                        );
                        let info = _this.$shell("SaveFileStream", [
                          _this.myInfo.id,
                          base64,
                          "mp4",
                        ]);
                        info = JSON.parse(info);
                        _this.pushPlayerOptions(
                          oArr[i].messageId,
                          info.return_msg
                        );
                        let gpsstr = `('${sendName}','${rId}','${sId}','${oArr[i].type}','${ist.name}','${oArr[i].time}','${oArr[i].messageId}','0','1','${info.return_msg}','${ist.id}','${ist.duration}','${fontSize}','${replay}')`;
                        _this.insertOffData(sId, gpsstr, oGroup, oTime, rId);
                        if (isToJudge) _this.searchAndSaveUser(sId);
                        _this.updateSessionChat(
                          sId,
                          rId,
                          sName,
                          rName,
                          ist.name,
                          oArr[i].time,
                          oGroup,
                          oArr[i].messageId,
                          oArr[i].type,
                          ist.duration,
                          info.return_msg,
                          ist.id
                        );
                      };
                      fileReader.readAsDataURL(wt);
                    },
                    (wt) => {
                      console.warn("error", wt);
                    }
                  );
                  // oStr1 +=
                  // 	`('${sendName}','${rId}','${sId}','${oArr[i].type}','${ist.name}','${oArr[i].time}','${oArr[i].messageId}','0','1','${ist.url}','${ist.id}','${ist.duration}','${fontSize}'),`
                  // if (oTime < oArr[i].time) oTime = oArr[i].time;
                  // if (isToJudge) this.searchAndSaveUser(sId);
                  // if(this.reconnect){
                  // 	this.updateSessionChat(sId,rId,sName,rName,ist.name,oArr[i].time,oGroup,oArr[i].messageId,oArr[i].type,ist.duration,ist.url,ist.id,0);
                  // }
                } else if (oArr[i].type == "file") {
                  oStr1 += `('${sendName}','${rId}','${sId}','${oArr[i].type}','${ist.name}','${oArr[i].time}','${oArr[i].messageId}','0','1','0',"${ist.id}",'${ist.duration}','${fontSize}','${replay}'),`;
                  if (oTime < oArr[i].time) oTime = oArr[i].time;
                  if (isToJudge) this.searchAndSaveUser(sId);
                  if (this.reconnect) {
                    this.updateSessionChat(
                      sId,
                      rId,
                      sName,
                      rName,
                      ist.name,
                      oArr[i].time,
                      oGroup,
                      oArr[i].messageId,
                      oArr[i].type,
                      ist.duration,
                      0,
                      ist.id,
                      0
                    );
                  }
                } else if (oArr[i].type == "article") {
                  let articleValue = JSON.parse(oArr[i].value);
                  this.installArticle(articleValue);
                }
              }
              oStr1 = oStr1.replace(/\,$/, "");
              console.log(oStr1, 2376);
              this.insertOffData(offid, oStr1, oGroup, oTime, rId);
            } else if (body.type == "3") {
              //广播离线
              console.log(this.receiveInfo, "离线消息广播1002");
              let broadOfflineList = body.content.sections[0].items || [];
              for (let i = 0; i < broadOfflineList.length; i++) {
                if (broadOfflineList[i].messagetype == "9") {
                  continue; //撤回广播，不入库
                }
                let value = JSON.parse(broadOfflineList[i].value);
                //存入fileMap的数据
                let fileMap = value.attach
                  ? this.$utilJs.backFileMap(value.attach)
                  : "";
                let bStr = `('${broadOfflineList[i].sendId}','${value.value}','${value.title}','${broadOfflineList[i].time}','${broadOfflineList[i].messageId}','0','1','${value.attachsize}','${value.attach}','${value.attachName}','${value.aType}','${fileMap}','${value.sendDeptIds}','${value.sendUserName}')`;
                this.insertOffBroad(broadOfflineList[i].sendId, bStr);
              }
            } else if (body.type == "4") {
              //公众号离线
            } else if (body.type == "5") {
              let calendarArr = body.content.sections[0].items || [];
              for (let i = 0; i < calendarArr.length; i++) {
                let value = JSON.parse(calendarArr[i].value);
                let calendarData = this.$utilJs.upperJSONKey(value);
                this.calendarList.push(calendarData);
              }
              this.$forceUpdate();
            } else if (body.type == "6") {
              let disposalArr = body.content.sections[0].items || [];
              for (let i = 0; i < disposalArr.length; i++) {
                let value = JSON.parse(disposalArr[i].value);
                let calendarData = this.$utilJs.upperJSONKey(value);
                this.noticeList.push(calendarData);
                console.log(this.noticeList, x);
              }
              this.$forceUpdate();
            }
            if (body.content.sections[0].items.length < 50) {
              this.chatList = [[], []];
              this.getMessageRecord(1);
              this.$forceUpdate();
            }
            this.getOffline(
              body.userId,
              body.type,
              body.total,
              body.times,
              body.farBack
            );
          } else if (body.isEnd == "1" && body.farBack == "0") {
            console.log("1.3.1002离线结束,5天内的");
            this.getOffline(body.userId, body.type, body.total, 0, "1");
          } else {
            for (let i = 0; i < this.sessionList.length; i++) {
              if (this.sessionList[i].id == body.userId) {
                this.sessionList[i].offline = false;
                console.log(
                  this.sessionList[i],
                  "找到了当前对话,修改离线结束状态"
                );
                break;
              }
            }
            console.log("1.3.1002离线结束,5天前的");
          }
        }
        else if (head.method == "1.2.2001" || head.method == "1.2.1001") {
          console.log(this.receiveInfo, 3703);
          // return
          // 在线单聊群聊
          let res = body.content.sections[0].items[0];
          let isSaveDataDb = true; //判断操作数据库是否成功
          let saveDataObject = null; //操作数据库返回对象
          // 新增消息回执 1.2.1001
          let messageId = body.messageKey;

          let isCur = head.method == "1.2.1001"; //私聊 //是否是群 0

          let isGroup = isCur ? "0" : "1";
          let rId = isCur ? body.receiveUserId : body.groupId;
          let sId = isCur ? body.sendUserId : body.userId;
          console.log(sId, "发送人ID");
          const toInfoId = isCur ? body.sendUserId : body.groupId; //发送人id或群id
          const isCurChat = toInfoId == this.toInfo.id; //是当前聊天人
          let isServiceAcc = body.isServiceAcc == 1 ? 1 : 0; //是否是客服消息
          console.log("isServiceAcc", isServiceAcc, head.method, body);
          // 开启循环发送 未发送成功的消息 每60秒执行一次
          // if(sId == this.myInfo.id) this.againSendFailMsg();
          //更新当前消息的发送状态
          const sqlTableType =
            head.method == "1.2.1001"
              ? this.sqlTable.privateList
              : this.sqlTable.messageList;
          tools.operationalDatabase(
            `UPDATE ${sqlTableType} SET isSuccessSend = '0' WHERE messageId = '${messageId}'`
          );
          let flag = true;
          for (let i in this.chatList) {
            if (!flag) {
              break;
            }
            for (let j in this.chatList[i]) {
              if (this.chatList[i][j].messageId == body.messageKey) {
                this.$set(this.chatList[i][j], "isSuccessSend", 0);
                flag = false;
                break;
              }
            }
          }

          if (isGroup == "0" && body.sendUserId != this.myInfo.id) {
            //接受消息后同步发送方在线状态
            let flag = this.sessionList.some((val) => {
              return val.id == body.sendUserId && val.status == "7";
            });
            if (flag) {
              this.updateSessionListStatus(body.sendUserId); //更新好友状态
            }
          }
          // 0未读 1已读
          let isRead = 0;
          if (isGroup == "1") {
            isRead = rId == this.toInfo.id || sId == this.myInfo.id ? 1 : 0;
          } else {
            isRead = sId == this.toInfo.id || sId == this.myInfo.id ? 1 : 0;
          }
          let data = JSON.parse(res.value);
          let sGender = data.gender;
          let replay = data.replay ? data.replay : "";
          let headUrl = data.head || "";
          let time = body.content.timestamp;
          let table = isCur
            ? this.sqlTable.privateList
            : this.sqlTable.messageList;
          let rValue =
            res.type == "text" ||
              res.type == "revocation" ||
              res.type == "shareGroup"
              ? data.text
              : res.type == "GPS"
                ? data.text
                : data.id;
          // console.log(data, rValue, '接收到消息的data')
          if (isServiceAcc == 1 && sId != this.myInfo.id) {
            data.sendName = "☆技术支持☆";
            data.head = "";
            // sId = 10000
          }
          if (
            data.duration &&
            data.duration != -1 &&
            data.duration != 32 &&
            data.duration != 1
          ) {
            // 解决APP发送的文件缺少isDownLoad、DownLoadId字段，导致无法下载
            data.isDownLoad = 0;
            data.DownLoadId = data.id;
          }
          let fontSize = data.fontSize || 14;
          let ismysend = tools.operationalDatabase(
            `SELECT * FROM ${table} WHERE messageId='${head.key}';`,
            1
          );

          console.log(table, ismysend, 2491);
          if (!ismysend.success) {
            //执行失败记录不返回
            isSaveDataDb = false;
          }
          let type = res.type;
          console.log(
            "aWindowS==>",
            this.activeWindowState,
            !this.activeWindowState
          );
          console.log(
            "chatingS==>",
            this.chating,
            this.activeWindowState && !this.chating
          );
          // 收到消息提醒
          if (
            !this.activeWindowState ||
            (this.activeWindowState && !this.chating) ||
            (this.activeWindowState && !isCurChat)
          ) {
            //zk增加，窗口激活但不处于聊天状态触发消息提醒
            if (sId != this.myInfo.id && res.type != "video") {
              let gender = isGroup == 1 ? 1 : data.gender == 1 ? 4 : 5;
              console.log("单聊群聊1", ismysend);
              // 2022/6/27 新增如果收到的消息重复并且是撤回，则更新右下角消息提醒
              if (ismysend.list.length <= 0) {
                console.log("数据库不存在此条消息,提醒一次,不会重复提醒");
                this.messageTips(
                  isCur ? body.sendUserId : body.groupId,
                  type,
                  rValue,
                  isCur ? headUrl : "",
                  isCur ? data.sendName : data.receiveName,
                  gender,
                  messageId
                );
              } else {
                if (type == "revocation") {
                  let messageTipId = isCur ? body.sendUserId : body.groupId;
                  console.log(this.messageTipsArr, messageTipId, 2656);
                  if (
                    this.messageTipsArr &&
                    this.messageTipsArr[messageTipId] &&
                    this.messageTipsArr[messageTipId].length > 0
                  ) {
                    this.messageTipsArr[messageTipId].forEach((item, index) => {
                      if (item[5] == messageId) {
                        this.messageTipsArr[messageTipId].splice(index, 1);
                        if (this.messageTipsArr[messageTipId].length == 0) {
                          delete this.messageTipsArr[messageTipId];
                        }
                        this.showTips();
                      }
                    });
                  }
                }
              }
            }
          }
          if (
            ismysend.list.length > 0 &&
            (type == "file" || type == "image" || type == "audio") &&
            sId == this.myInfo.id
          ) {
            //收到消息回执修改文件下载id
            let esw = tools.operationalDatabase(
              `UPDATE ${table} SET DownLoadId='${rValue}' WHERE messageId='${head.key}';`
            );
            //图片文件暂不同步服务器时间，避免顺序混乱
            // tools.operationalDatabase(`UPDATE ${table} SET time = "${time}" WHERE messageId = "${head.key}"`)

            console.log(
              "消息回执:",
              `UPDATE ${table} SET DownLoadId='${rValue}' WHERE messageId='${head.key}';`
            );

            let userIds = rId == this.myInfo.id ? sId : rId;
            if (isGroup) {
              //cxr0615未知修复
              userIds = body.groupId;
            }
            if (userIds) {
              tools.operationalDatabase(
                `REPLACE INTO ${this.sqlTable.sessionList}(userId,isGroup,time) VALUES ('${userIds}','${isGroup}','${time}');`
              );
            }
          } else if (
            (type == "file" ||
              type == "image" ||
              type == "audio" ||
              type == "video") &&
            (sId != this.myInfo.id ||
              (sId == this.myInfo.id && ismysend.list.length == 0))
          ) {
            if (type == "image") {
              if (ismysend.list.length == 0) {
                isSaveDataDb = false;
                // 2022/5/16 zc修改 先入库插入加载图片，避免时间混乱
                _this.insertData(
                  data.sendName,
                  rId,
                  sId,
                  type,
                  "",
                  time,
                  head.key,
                  isRead,
                  "0",
                  data.url,
                  rValue,
                  data.duration,
                  isGroup,
                  fontSize,
                  headUrl,
                  replay,
                  isServiceAcc
                );
                _this.updateSessionChat(
                  sId,
                  rId,
                  data.sendName,
                  data.receiveName,
                  "",
                  time,
                  isGroup,
                  body.messageKey,
                  type,
                  data.duration,
                  data.url,
                  data.DownLoadId || data.id,
                  replay,
                  fontSize,
                  sGender,
                  headUrl
                );

                console.log(rValue, messageId, head.key, 2598);

                this.$downLoad(
                  "api/v1/oim/image/downloadsmall.do",
                  rValue,
                  (wt) => {
                    console.log(
                      wt,
                      rValue,
                      messageId,
                      head.key,
                      "wtdownloadsmall"
                    );
                    var fileReader = new FileReader();
                    fileReader.onload = function (w) {
                      let info = '{"return_msg":""}';
                      if (wt.size !== 0) {
                        //下载接口正常返回，通过外壳获取图片地址
                        let base64 = w.target.result.replace(
                          /^data\:.{1,40}base64\,/gi,
                          ""
                        );
                        let arr = data.name.split(".").splice(-1)[0];
                        info = _this.$shell("SaveFileStreamczs", [
                          _this.myInfo.id,
                          rValue,
                          arr,
                          base64,
                          0,
                        ]);
                      }

                      info = JSON.parse(info);
                      console.log("图片", info);
                      _this.insertData(
                        data.sendName,
                        rId,
                        sId,
                        type,
                        info.return_msg,
                        time,
                        head.key,
                        isRead,
                        "0",
                        data.url,
                        rValue,
                        data.duration,
                        isGroup,
                        fontSize,
                        headUrl,
                        replay,
                        isServiceAcc
                      );
                      // 2022/5/16 zc修改 图片二次更新
                      _this.updateSessionChat(
                        sId,
                        rId,
                        data.sendName,
                        data.receiveName,
                        info.return_msg,
                        time,
                        isGroup,
                        body.messageKey,
                        type,
                        data.duration,
                        data.url,
                        data.DownLoadId || data.id,
                        replay,
                        fontSize,
                        sGender,
                        headUrl,
                        false
                      );
                      if (
                        _this.isSaved ||
                        (sId == _this.myInfo.id && ismysend.list.length == 0)
                      ) {
                        console.log(66666666);
                        _this.updateSessionChat(
                          sId,
                          rId,
                          data.sendName,
                          data.receiveName,
                          info.return_msg,
                          time,
                          isGroup,
                          body.messageKey,
                          type,
                          data.duration,
                          data.url,
                          data.DownLoadId || data.id,
                          replay,
                          fontSize,
                          sGender,
                          headUrl
                        );
                      }
                    };

                    fileReader.readAsDataURL(wt);
                    this.$getMes(this.myInfo.id, messageId);
                  },
                  (wt) => {
                    console.warn("error", wt);
                  }
                  // false
                );
              } else {
                console.log("重复图片消息,不调接口");
              }
            } else if (type == "audio") {
              data.url =
                this.$store.state.url +
                "api/v1/oim/file/download.do?id=" +
                data.id;
              saveDataObject = this.insertData(
                data.sendName,
                rId,
                sId,
                type,
                data.name,
                time,
                head.key,
                isRead,
                "0",
                data.url,
                rValue,
                data.duration,
                isGroup,
                fontSize,
                headUrl,
                replay,
                isServiceAcc
              );
              if (
                this.isSaved ||
                (sId == this.myInfo.id && ismysend.list.length == 0)
              ) {
                this.updateSessionChat(
                  sId,
                  rId,
                  data.sendName,
                  data.receiveName,
                  data.name,
                  time,
                  isGroup,
                  body.messageKey,
                  type,
                  data.duration,
                  data.url,
                  0,
                  replay,
                  fontSize,
                  sGender,
                  headUrl
                );
              }
              if (!saveDataObject.success) {
                //执行失败不通知服务器
                isSaveDataDb = false;
              }
            } else if (type == "file") {
              saveDataObject = this.insertData(
                data.sendName,
                rId,
                sId,
                type,
                data.name,
                time,
                head.key,
                isRead,
                "0",
                data.isDownLoad == "1" ? "1" : "0",
                rValue,
                data.duration,
                isGroup,
                fontSize,
                headUrl,
                replay,
                isServiceAcc
              );
              if (
                this.isSaved ||
                (sId == this.myInfo.id && ismysend.list.length == 0)
              ) {
                this.updateSessionChat(
                  sId,
                  rId,
                  data.sendName,
                  data.receiveName,
                  data.name,
                  time,
                  isGroup,
                  body.messageKey,
                  type,
                  data.duration,
                  data.isDownLoad,
                  data.DownLoadId,
                  replay,
                  fontSize,
                  sGender,
                  headUrl
                );
              }
              if (!saveDataObject.success) {
                //执行失败不通知服务器
                isSaveDataDb = false;
              }
            } else if (type == "video") {
              // let msga_list = tools.operationalDatabase(
              //   `SELECT a.*,b.* FROM ${this.sqlTable.privateList} a,${this.sqlTable.messageList} b WHERE a.DownLoadId='${rValue}' OR b.DownLoadId='${rValue}';`,
              //   1
              // );
              let msga_list = tools.operationalDatabase(
                `SELECT * from ${this.sqlTable.privateList} where DownLoadId='${rValue}' union SELECT * from ${this.sqlTable.messageList} where DownLoadId='${rValue}';`,
                1
              );

              if (msga_list.list.length > 0) {
                _this.pushPlayerOptions(
                  body.messageKey,
                  msga_list.list[0].isDownLoad
                );
                saveDataObject = _this.insertData(
                  data.sendName,
                  rId,
                  sId,
                  type,
                  data.name,
                  time,
                  head.key,
                  isRead,
                  "0",
                  msga_list.list[0].isDownLoad,
                  rValue,
                  data.duration,
                  isGroup,
                  fontSize,
                  headUrl,
                  replay,
                  isServiceAcc
                );
                if (
                  _this.isSaved ||
                  (sId == _this.myInfo.id && ismysend.list.length == 0)
                ) {
                  _this.updateSessionChat(
                    sId,
                    rId,
                    data.sendName,
                    data.receiveName,
                    data.name,
                    time,
                    isGroup,
                    body.messageKey,
                    type,
                    data.duration,
                    msga_list.list[0].isDownLoad,
                    // data.DownLoadId,
                    data.DownLoadId || data.id, //zk0217修改，解决收藏视频downloadid为空
                    replay,
                    fontSize,
                    sGender,
                    headUrl
                  );
                }
                // if(!_this.activeWindowState){
                if (sId != _this.myInfo.id) {
                  console.log("单聊群聊2");
                  _this.messageTips(
                    isCur ? body.sendUserId : body.groupId,
                    type,
                    rValue,
                    isCur ? headUrl : "",
                    isCur ? data.sendName : data.receiveName,
                    isGroup
                  );
                }
                // }
                if (!saveDataObject.success) {
                  //执行失败不通知服务器
                  isSaveDataDb = false;
                }
              } else {
                isSaveDataDb = false;
                this.$downLoad(
                  "api/v1/oim/file/download.do",
                  rValue,
                  (wt) => {
                    var fileReader = new FileReader();
                    fileReader.onload = function (w) {
                      let base64 = w.target.result.replace(
                        /^data\:.{1,40}base64\,/gi,
                        ""
                      );
                      let info = _this.$shell("SaveFileStream", [
                        _this.myInfo.id,
                        base64,
                        "mp4",
                      ]);
                      info = JSON.parse(info);
                      _this.insertData(
                        data.sendName,
                        rId,
                        sId,
                        type,
                        data.name,
                        time,
                        head.key,
                        isRead,
                        "0",
                        info.return_msg,
                        rValue,
                        data.duration,
                        isGroup,
                        fontSize,
                        headUrl,
                        replay
                      );
                      if (_this.isSaved) {
                        _this.updateSessionChat(
                          sId,
                          rId,
                          data.sendName,
                          data.receiveName,
                          data.name,
                          time,
                          isGroup,
                          body.messageKey,
                          type,
                          data.duration,
                          info.return_msg,
                          // data.DownLoadId,
                          data.DownLoadId || data.id, //zk0217修改，解决收藏视频downloadid为空
                          replay,
                          fontSize,
                          sGender,
                          headUrl
                        );
                      }
                      _this.pushPlayerOptions(body.messageKey, info.return_msg);
                      // if(!_this.activeWindowState){
                      if (sId != _this.myInfo.id) {
                        console.log("单聊群聊3");
                        _this.messageTips(
                          isCur ? body.sendUserId : body.groupId,
                          type,
                          rValue,
                          isCur ? headUrl : "",
                          isCur ? data.sendName : data.receiveName,
                          isGroup
                        );
                      }
                      // }
                    };
                    fileReader.readAsDataURL(wt);
                    this.$getMes(this.myInfo.id, messageId);
                  },
                  (wt) => {
                    console.warn("error", wt);
                  }
                );
              }
            } else {
              saveDataObject = this.insertData(
                data.sendName,
                rId,
                sId,
                type,
                data.name,
                time,
                head.key,
                isRead,
                "0",
                "0",
                rValue,
                data.duration,
                isGroup,
                fontSize,
                headUrl,
                replay,
                isServiceAcc
              );
              console.warn(this.isSaved, saveDataObject);
              alert(1);
              if (
                this.isSaved ||
                (sId == this.myInfo.id && ismysend.list.length == 0)
              ) {
                this.updateSessionChat(
                  sId,
                  rId,
                  data.sendName,
                  data.receiveName,
                  data.name,
                  time,
                  isGroup,
                  body.messageKey,
                  type,
                  data.duration,
                  0,
                  0,
                  replay,
                  fontSize,
                  sGender,
                  headUrl
                );
              }
              if (!saveDataObject.success) {
                //执行失败不通知服务器
                isSaveDataDb = false;
              }
            }
          } else {
            if (type == "GPS") rValue = JSON.stringify(rValue);
            // 同屏
            if (type == "screen") rValue = data.text;
            saveDataObject = this.insertData(
              data.sendName,
              rId,
              sId,
              type,
              rValue,
              time,
              body.messageKey,
              isRead,
              "0",
              "0",
              "0",
              -1,
              isGroup,
              fontSize,
              headUrl,
              replay,
              isServiceAcc
            );
            if (this.isSaved) {
              this.updateSessionChat(
                sId,
                rId,
                data.sendName,
                data.receiveName,
                rValue,
                time,
                isGroup,
                body.messageKey,
                type,
                0,
                0,
                0,
                replay,
                fontSize,
                sGender,
                headUrl
              );
            }
            if (!saveDataObject.success) {
              //执行失败不通知服务器
              isSaveDataDb = false;
            }
          }
          // 自动回复时,防止无限发，zk1215标识，收到消息自动回复
          if (this.cur_state != "" && isCur && sId != this.myInfo.id) {
            let value = JSON.parse(res.value);
            if (!value.curState) {
              this.$wsSendMsg(
                {
                  id: sId,
                  isGrup: "0",
                },
                this.$func.uuid(),
                "text",
                {
                  text: this.cur_state,
                  gender: this.myInfo.gender || "1",
                  head: this.myInfo.head || "",
                  curState: true,
                },
                this.ws
              );
            }
          }

          if (isSaveDataDb) {
            //向服务端确认入库回执
            this.$getMes(this.myInfo.id, messageId);
          }

          // 已读未读单聊
        }
        else if (head.method == "1.2.1003") {
          let messagebody = this.receiveInfo.body;
          console.log(
            messagebody,
            this.chatList,
            "已读未读返回的1数据.1.2005=>消息列表"
          );
          //收到已读消息的回执

          //   console.log(utilJs.sendMessageRead, 4321);
          // setTimeout(() => {
          //    console.log(this.$utilJs.sendMessageRead, 4323);
          // }, 1000);
          this.ws.send(
            this.$utilJs.sendMessageRead(this.myInfo.id, messagebody.messageKey)
          );

          if (messagebody.receiveUserId == this.toInfo.id) {
            for (let i in this.chatList) {
              for (let j in this.chatList[i]) {
                if (
                  messagebody.timestamp - this.chatList[i][j].time >= 0 ||
                  messagebody.messageKey == this.chatList[i][j].messageId
                ) {
                  console.log();
                  this.$set(this.chatList[i][j], "isByRead", "1");
                }
              }
            }
            //在线单聊已读更新到currenttempchat
            for (let i in this.currentTempChat) {
              for (let j in this.currentTempChat[i]) {
                if (
                  messagebody.timestamp - this.currentTempChat[i][j].time >=
                  0 ||
                  messagebody.messageKey == this.currentTempChat[i][j].messageId
                ) {
                  this.$set(this.currentTempChat[i][j], "isByRead", "1");
                }
              }
            }
          }
          let rep = tools.operationalDatabase(
            // 更改数据库未读状态
            `UPDATE
              ${this.sqlTable.privateList}
            SET
              isByRead='1'
            WHERE
              (receiveId='${messagebody.receiveUserId}'
              AND sendId='${messagebody.sendUserId}'
              AND isByRead != '1');`
          );
        }
        else if (head.method == "1.2.2002") {
          // 已读未读群聊
          let messagebody = this.receiveInfo.body;
          console.log(messagebody, "已读未读返回的数据1.1.2005");
          //收到已读消息的回执
          this.ws.send(
            this.$utilJs.sendMessageRead(this.myInfo.id, messagebody.messageKey)
          );

          if (messagebody.groupId == this.toInfo.id) {
            for (let i in this.chatList) {
              for (let j in this.chatList[i]) {
                if (this.chatList[i][j].messageId == messagebody.messageKey) {
                  if (messagebody.data) {
                    this.$set(
                      this.chatList[i][j],
                      "readData",
                      JSON.stringify(messagebody.data)
                    );
                  }
                }
              }
            }
            //群聊已读更新到currenttempchat
            for (let i in this.currentTempChat) {
              for (let j in this.currentTempChat[i]) {
                if (
                  this.currentTempChat[i][j].messageId == messagebody.messageKey
                ) {
                  if (messagebody.data) {
                    this.$set(
                      this.currentTempChat[i][j],
                      "readData",
                      JSON.stringify(messagebody.data)
                    );
                  }
                }
              }
            }
          }
          if (messagebody.data) {
            let rep = tools.operationalDatabase(
              // 更新数据库未读成员
              `UPDATE ${this.sqlTable.messageList
              } SET readData='${JSON.stringify(
                messagebody.data
              )}' WHERE messageId='${messagebody.messageKey}';`
            );
          }
          this.$forceUpdate();
        }
        else if (head.method == "1.2.3001") {
          //zk128注释，接收方接到远程控制请求
          try {
            this.toControlLabel = parseInt(body.label) || 2;
          } catch (err) {
            this.toControlLabel = 2;
          }
          if (!this.$store.state.connectRemoteServer) {
            //不是连接状态，先注册
            this.$remoteControlConnect();
          }
          if (
            this.control_type == 1 ||
            this.control_type == 2 ||
            this.control_type == 3 ||
            this.control_type == 4 ||
            this.control_type == 5
          ) {
            let initid = this.$func.uuid();
            this.ws.send(
              this.$publicSend(initid, "1.500", "1.1.1017", {
                label: this.toControlLabel,
                requestId: this.myInfo.id,
                receptionId: body.requestId,
                type: 1,
              })
            );
            return;
          }
          let requestId = body.requestId || ""; //请求id
          this.toRegisterid = body.registerid || "";
          this.toControlPassword = body.password || "";
          this.getUserInfo(
            requestId,
            (data) => {
              if (data.result == 200) {
                this.requestUser = data.data;
                console.log(data, this.$store.state.myInfo);
                if (
                  data.data.macAddress != this.$store.state.myInfo.macAddress
                ) {
                  //zk128新增，接收方判断是否为同一台电脑，是的话就不显示远程控制组件
                  // zk0303新增，获取我授权出去的直接远程名单
                  let users = this.$remoteControl("GetBindUsers", [
                    this.myInfo.id,
                  ]); //60
                  users = JSON.parse(users);
                  console.log("GetBindUsers返回", users);
                  this.setAuthMembers(users.Data);

                  this.controlViwe_show = true;

                  //zk0303新增，判断不是同一台电脑，直接开启同屏
                  this.$nextTick(() => {
                    for (let i in this.authMembers) {
                      if (requestId == this.authMembers[i].LoginID) {
                        this.$refs.remoteControl.remoteConfirm();
                        break;
                      }
                    }
                  });
                } else {
                  //是同一台电脑，关闭并且可以再次请求
                  this.controlViwe_show = false;
                  this.control_type = 0;
                }
              }
            },
            (res) => { }
          );
          if (body.type == 1) {
            this.control_type = 3; //远程控制
            this.remoteType = 2;
            this.remoteState = 3;
          } else if (body.type == 2) {
            this.remoteState = 4; //远程协助
            this.remoteType = 1;
            this.control_type = 4;
          }
        }
        else if (head.method == "1.2.3002") {
          //接收远程功能事件通知
          let type = body.type;
          if (type == 1) {
            this.$Message.warning("对方拒绝了远程请求");
            this.controlViwe_show = false;
            this.control_type = 6;
          } else if (type == 2) {
            this.$Message.warning("对方中止了远程操作");
            if (this.control_type == 5 && this.remoteType == 1) {
              this.remoteType = 0;
              let res = this.$remoteControl("CloseRemote", []);
            }
            this.control_type = 6;
            this.remoteState = 6;
          }
        }
        else if (head.method == "1.2.3003") {
          //接收远程功能事件通知
          this.toRegisterid = body.registerid || "";
          this.toControlPassword = body.password || "";
          this.controlViwe_show = true;
          if (this.control_type == 1) {
            let res = this.$remoteControl("OpenRemote", [
              this.toRegisterid,
              this.toControlPassword,
            ]);
            res = JSON.parse(res);
            if (res.return_code == "TRUE") {
              this.control_type == 5;
            } else {
              this.$Message.warning(res.return_msg);
            }
          }
        }
        else if (head.method == "1.1.1016") {
          if (!socketInfo.success) {
            this.$Message.warning(
              socketInfo.errors[0].text || "远程控制建立发生错误"
            );
            this.remoteState = 0;
          }
        }
        else if (head.method == "1.2.4000") {
          //zk新增，在线时个人文件是否已下载
          let messageid = body.messageKey;
          for (let i in this.chatList) {
            for (let j in this.chatList[i]) {
              if (this.chatList[i][j].messageId == messageid) {
                this.$set(this.chatList[i][j], "downloaded", 1);
              }
            }
          }
          //在线个人下载状态更新到currenttempchat
          for (let i in this.currentTempChat) {
            for (let j in this.currentTempChat[i]) {
              if (this.currentTempChat[i][j].messageId == messageid) {
                this.$set(this.currentTempChat[i][j], "downloaded", 1);
              }
            }
          }
          //判断downloaded字段是否存在,不存在就添加
          let isDownloaded = tools.operationalDatabase(
            `select * from sqlite_master where name = '${this.sqlTable.privateList}' and sql like 'downloaded';`,
            1
          );
          if (isDownloaded.list.length == 0)
            tools.operationalDatabase(
              `ALTER TABLE ${this.sqlTable.privateList} ADD COLUMN downloaded INTEGER;`
            );
          if (messageid) {
            let rep = tools.operationalDatabase(
              // 更新数据库
              `UPDATE ${this.sqlTable.privateList} SET downloaded=1 WHERE messageId='${messageid}';`
            );
          }
        }
        else if (head.method == "1.2.4002") {
          //zk新增，在线时群文件被下载
          console.log(body);
          // 群聊是否已下载
          let messagebody = this.receiveInfo.body;
          if (messagebody.groupId == this.toInfo.id) {
            for (let i in this.chatList) {
              for (let j in this.chatList[i]) {
                if (this.chatList[i][j].messageId == messagebody.messageKey) {
                  if (messagebody.data) {
                    this.$set(
                      this.chatList[i][j],
                      "downloadData",
                      JSON.stringify(messagebody.data)
                    );
                  }
                }
              }
            }
            //zk1218新增，在线群下载状态更新到currenttempchat
            for (let i in this.currentTempChat) {
              for (let j in this.currentTempChat[i]) {
                if (
                  this.currentTempChat[i][j].messageId == messagebody.messageKey
                ) {
                  if (messagebody.data) {
                    this.$set(
                      this.currentTempChat[i][j],
                      "downloadData",
                      JSON.stringify(messagebody.data)
                    );
                  }
                }
              }
            }
          }
          let isDownloaded = tools.operationalDatabase(
            `select * from sqlite_master where name = '${this.sqlTable.messageList}' and sql like 'downloadData';`,
            1
          );
          if (isDownloaded.list.length == 0)
            tools.operationalDatabase(
              `ALTER TABLE ${this.sqlTable.messageList} ADD COLUMN downloadData TEXT;`
            );
          if (messagebody.data) {
            let rep = tools.operationalDatabase(
              // 更新数据库未读成员
              `UPDATE ${this.sqlTable.messageList
              } SET downloadData='${JSON.stringify(
                messagebody.data
              )}' WHERE messageId='${messagebody.messageKey}';`
            );
          }
          this.$forceUpdate();
        }
        else if (head.method == "1.1.8888") {
          //公文发布通知
          this.getRemind();
        }
        else if (head.method == "1.9.9999") {
          //消息删除
          console.log("消息删除", body, head);
          // 消息类型 : 1.个人、2.群、3.广播、公告、7.文章、8.公文
          switch (parseInt(body.type)) {
            case 1:
              this.deletePrivateInit(body.messageKey); // 个人消息
              break;
            case 2:
              this.deleteMessageInit(body.messageKey); // 群消息
              break;
            case 3:
              this.deleteBroadInit(body.messageKey); // 广播
              break;
            case 7:
              this.deleteArticleInit(body.messageKey); // 文章
          }
        }
        else if (head.method == "1.1.1004") {
          console.log("漫游消息");
        }
        else if (head.method == "1.6.0001") {
          // 2022/4/12 zc新增 软件信息采集内容转发给外壳
          let softInfo = this.receiveInfo.body.data;
          console.log("收到软件信息采集信息", softInfo);

          this.$softWareInformation("Distribute", [
            this.$store.state.myInfo.id,
            this.$store.state.myInfo.name,
            softInfo,
          ]);
        }
      }
      else if (head.action == "1.501") {
        if (head.method == "1.1.0001") {
          // 广播通知
          let value = body.content.sections[0].items[0].value;
          // this.messageTips(
          //   "69f175b9-45d3-45e0-87fc-4cbeeff97887",
          //   "text",
          //   value,
          //   "",
          //   "广播通知",
          //   "3"
          // );
          // 新增判断表字段（aType）是否存在
          let isAtype = tools.operationalDatabase(
            `select * from sqlite_master where name = '${this.sqlTable.broadcastList}' and sql like 'aType';`,
            1
          );
          if (isAtype.list.length == 0)
            tools.operationalDatabase(
              `ALTER TABLE ${this.sqlTable.broadcastList} ADD COLUMN aType CHAR(1);`
            );

          // 存入fileMap的数据
          let fileMap = this.$utilJs.backFileMap(body.attach);
          this.insertBroad(
            body.userId,
            value,
            body.title,
            body.content.timestamp,
            body.messageKey,
            "0",
            "1",
            body.attachsize,
            body.attach,
            body.attachName,
            body.aType,
            fileMap,
            body.deptIds,
            body.sendUserName
          );
          if (this.workList[1].show) {
            let res = tools.operationalDatabase(
              `SELECT a.*,b.* FROM ${this.sqlTable.broadcastList} AS a,${this.sqlTable.userInformation} AS b WHERE a.broadSendId = b.id ORDER BY time DESC;`,
              1
            );
            this.broadList = res.list || [];
            for (let i = 0; i < this.broadList.length; i++) {
              if (
                this.broadList[i].attachName &&
                this.broadList[i].attachName != ""
              ) {
                let attachName = this.broadList[i].attachName.split(",");
                let attachsize = this.broadList[i].attachsize.split(",");
                let attach = this.broadList[i].attachsize.split(",");
                if (attachName.length > 0) {
                  this.broadList[i].files = [];
                  for (let j = 0; j < attachName.length; j++) {
                    this.broadList[i].files.push({
                      attachName: attachName[j],
                      attachsize: attachsize[j],
                      attach: attach[j],
                    });
                  }
                }
              } else {
                this.broadList[i].files = [];
              }
            }
            this.$refs.myBroadcastnotification.broadSearchFn();
            // this.broadSearchFn(); //防止在广播通知界面，收到新广播后，第一页显示超过50条（显示全部）
          }
          this.$set(
            this.workList[1],
            "noRead",
            (parseInt(this.workList[1].noRead) || 0) + 1
          );
          // 更新广播未读数量
          this.getSessionBroad();
        }
      }
      // 用户重复登录
      if (head.action == "1.100") {
        if (head.method == "1.2.0001" && body.offline) {


          console.log(this.$store.state.autoOpeners, "收到重复登录推送");

          //zk15标识，被挤下线
          if (this.$refs.remoteControl) {
            this.$refs.remoteControl.close(); //zk15新增，被挤下线时关闭远程控制
          }
          if (this.$refs.homeChatMain) {
            this.$refs.homeChatMain.viewer &&
              this.$refs.homeChatMain.viewer.destroy(); //zk129新增，被挤下线之后关闭图片预览
          }
          // 同屏 退出登录 断开中转服务器 结束同屏
          this.overScreenFn();
          this.$store.state.initLogin = true;
          this.$store.state.ws.send(
            this.$loginJsonString(this.$func.uuid(), "1.100", "1.1.0049", {
              status: "9",
            })
          );
          this.$store.state.initStatus = true;
          this.$store.commit("set_soketConnect", true);
          window.offlineFn();
          setTimeout(() => {
            this.$shell("SetLoginUser", ["", "", "", "420", "460"]);
            this.$router.push({
              path: "/",
              query: {
                userOutLine: true,
              },
            });
          }, 3000);


          this.$store.state.autoOpeners.forEach(t => {
            if (t && t.postMessage) {

             t.postMessage('重复登录下线','*')
            }
          })
        }
        if (head.method == "1.1.0049") {
          this.exitLogin(); // 退出登录
        }
      }
      // 在线文章推送
      if (head.action == "6.000") {
        if (head.method == "6.1.0001") {
          let data = JSON.parse(body.data);
          let { sendId, head, sendName, gender, messageId } = data;
          let messageGender;
          this.installArticle(data);
          if (gender == "1") {
            messageGender = 4;
          } else {
            messageGender = 5;
          }
          // 2022/7/26 新增 在线文章推送右下角闪烁
          if (sendId == this.myInfo.id) {
            return;
          }
          this.messageTips(
            sendId,
            "article",
            "[文章]",
            head,
            sendName,
            messageGender,
            messageId
          );
        }
      }
      //同屏分享接口
      if (head.action == "1.300") {
        if (head.method == "1.3.1003") {
          let content = JSON.parse(body.content);
          let res = content.sections[0].items[0];
          let data = JSON.parse(res.value);
          let isGroup = 0;
          let rId = this.myInfo.id;
          let sId = body.sendUserId;
          let headUrl = data.head || "";
          let time = content.timestamp;
          this.insertData(
            data.sendUserName,
            rId,
            sId,
            res.type,
            res.value,
            time,
            body.messageKey,
            1,
            "0",
            "0",
            "0",
            -1,
            isGroup,
            14,
            headUrl,
            ""
          );
          this.updateSessionChat(
            sId,
            rId,
            data.sendUserName,
            this.myInfo.name,
            res.value,
            time,
            isGroup,
            body.messageKey,
            res.type,
            0,
            0,
            0,
            "",
            14,
            data.gender,
            headUrl
          );
        }
      }
      //管理端强制升级
      if (head.action == "1.701") {
        if (head.method == "1.x.0701") {
          alert(body.msg);
          const info = this.$shell("ManualUpdate", ["0"]);
          console.log(info, "==>手动升级");
          if (info && info.Return_code) {
            if (!info.IsNeedUpdate) {
              this.$message({
                message: "系统升级",
                type: "success",
              });
              //this.$shell("ClientUpdate", []);
            } else {
              this.$shell("ManualUpdate", ["1"]);
            }
          }
        }
      }
      //  资产待办推送
      if ((head.action = "1.506" && false)) {
        if ((head.method = "1.1.2001")) {
          console.log(body, "资产待办推送");
          try {
            let data = JSON.parse(body.data);
            let { sendId, head, sendName, gender, messageId } = data;
            let messageGender;
            // this.installArticle(data);
            // if (gender == "1") {
            //   messageGender = 4;
            // } else {
            //   messageGender = 5;
            // }
            // 2022/7/26 新增 在线文章推送右下角闪烁
            if (sendId == this.myInfo.id) {
              return;
            }

            this.messageTips(
              "remind",
              "assect",
              '[资产]',
              "",
              "待办提醒",
              "6",
              messageId
            );

            // this.messageTips(
            //   sendId,
            //   "assect",
            //   "[资产]",
            //   head,
            //   sendName,
            //   5,
            //   messageId
            // );
          } catch (err) {
            console.log(err, "资产待办推送解析失败");
          }
        }
      }
    },
    sendInfo() {
      console.log(JSON.parse(this.sendInfo), "sendInfo_watch");
      let head = JSON.parse(this.sendInfo).head;
      let result = JSON.parse(this.sendInfo).info.success;
      let body = JSON.parse(this.sendInfo).body;
      let personalList = body.personalList || [];
      let personalDownloadList = body.personalDownloadList || [];
      let groupList = body.groupList || [];
      let groupDownloadList = body.groupDownloadList || [];
      if (head.resultCode == 1) {
        if (head.action == "1.500") {
          if (head.method == "1.1.1001" || head.method == "1.1.2001") {
            if (body.code == "500") {
              //信息发送失败,用户不存在
              this.$Message.warning(body.msg);
              let flag = true;
              for (let i in this.chatList) {
                if (!flag) {
                  break;
                }
                for (let j in this.chatList[i]) {
                  if (this.chatList[i][j].messageId == head.key) {
                    this.$set(this.chatList[i][j], "isSuccessSend", 2);
                    flag = false;
                    break;
                  }
                }
              }
            }
          } else if (head.method == "1.1.1015") {
            console.log(result, "获取离线已读和已下载"); //zk注释
            if (result) {
              if (personalList.length > 0) {
                for (let i = 0; i < personalList.length; i++) {
                  let rep = tools.operationalDatabase(
                    //zk修改，发送失败不变已读AND isSuccessSend != '2'
                    `UPDATE ${this.sqlTable.privateList}
                    SET isByRead = '1'
                    WHERE
                      time<=${personalList[i].value.timestamp}
                      AND (receiveId='${personalList[i].value.receiveId}'
                      AND sendId='${this.myInfo.id}')
                      AND isSuccessSend != '2' ;`
                  );
                  console.log(rep, "离线已读未读更新");
                }
              }
              if (groupList.length > 0) {
                for (let i = 0; i < groupList.length; i++) {
                  let readDatas = {
                    unreadUsers: groupList[i].value.unreadUsers,
                    read: groupList[i].value.read,
                    unread: groupList[i].value.unread,
                    readUsers: groupList[i].value.readUsers,
                  };
                  console.log(JSON.stringify(readDatas));
                  let rep = tools.operationalDatabase(
                    `UPDATE ${this.sqlTable.messageList
                    } SET readData='${JSON.stringify(
                      readDatas
                    )}' WHERE receiveId='${groupList[i].value.groupId
                    }' AND messageId='${groupList[i].value.messageId}';`
                  );
                  console.log(rep, "群离线已读未读更新");
                }
              }
              if (personalDownloadList.length > 0) {
                for (let i = 0; i < personalDownloadList.length; i++) {
                  let rep = tools.operationalDatabase(
                    `UPDATE ${this.sqlTable.privateList} SET downloaded = 1 WHERE messageId='${personalDownloadList[i].messageId}';`
                  );
                  console.log(rep, "离线个人下载更新");
                }
              }
              if (groupDownloadList.length > 0) {
                for (let i = 0; i < groupDownloadList.length; i++) {
                  // {"unreadUsers":"","read":2,"unread":0,"readUsers":"111111,666666"}
                  let readDatas = {
                    unreadUsers: groupDownloadList[i].value.unreadUsers,
                    read: groupDownloadList[i].value.read,
                    unread: groupDownloadList[i].value.unread,
                    readUsers: groupDownloadList[i].value.readUsers,
                  };
                  console.log(JSON.stringify(readDatas));
                  let rep = tools.operationalDatabase(
                    `UPDATE ${this.sqlTable.messageList
                    } SET downloadData='${JSON.stringify(
                      readDatas
                    )}' WHERE receiveId='${groupDownloadList[i].value.groupId
                    }' AND messageId='${groupDownloadList[i].value.messageId}';`
                  );
                  console.log(rep, "群离线下载更新");
                }
              }
            }
          } else if (head.method == "1.1.2008") {
            if (result) {
              if (!body.contents) {
                this.$Message.warning(body.msg);
                return;
              }
              let resArr = body.contents;
              if (!resArr.length) {
                this.$Message.warning("暂无语录");
              }
              resArr.map((e) => {
                let valueArr = JSON.parse(e.VALUE);
                Object.assign(e, {
                  VALUE: valueArr,
                  SHOWDELETE: false,
                });
                // 新增下载头像
                valueArr.map((item) => {
                  // item.id = item.userId;//zk修改，禁止id修改
                  this.downLoadHeadPath(item);
                });
              });
              this.allText
                ? (this.quotationsList = resArr)
                : (this.allQuotationsList = resArr);
              this.allText ? (this.quotationsTotal = body.totalPage + 1) : 0;
              this.allText ? (this.currentPage = body.pageNumber + 1) : 0;
            }
          } else if (head.method == "1.1.2006") {
            if (result) {
              this.$Message.success(body.msg);
              let key = this.toInfo.id;
              let pageData = {
                pageNumber: 1,
                pageSize: 30,
              };
              this.ws.send(
                this.$publicSend(key, "1.500", "1.1.2008", {
                  groupId: this.toInfo.id,
                  page: pageData,
                })
              );
            } else {
              //info.success是false
              this.$Message.warning("您已添加过该条语录");
            }
          } else if (head.method == "1.1.2007") {
            //zk注释群语录删除
            if (result) {
              console.log(result, "删除语录成功的返回值");
              let key = head.key.split(",");
              key.map((e) => {
                let temArr = this.allQuotationsList;
                for (let i = 0; i < temArr.length; i++) {
                  if (temArr[i].VALUE.length) {
                    for (let k = 0; k < temArr[i].VALUE.length; k++) {
                      if (temArr[i].VALUE[k].id == e) {
                        temArr.splice(i, 1);
                        break;
                      }
                    }
                  }
                }
              });
              this.$Message.success("已成功删除");
              this.$forceUpdate();
            }
          } else if (head.method == "1.1.1004") {
            if (result) {
              this.allRecords = body.contents;
            }
          }
        }
        if (head.action == "1.501") {
          if (head.method == "1.1.0001") {
            if (result) {
              this.broadSendList = [];
              this.broadKey = new Date().getTime();
              this.$Message.success("广播发送成功");
              this.$refs.broadChild.broad_hidden();
            } else {
            }
          }
        }
        if (head.action == "1.101") {
          //新增判断远程控制是否为同一台电脑(根据有无head.resultCode)
          if (head.method == "1.1.0016") {
            if (
              body.userData &&
              body.userData.macAddress == this.$store.state.myInfo.macAddress
            ) {
              console.log("无法远程控制同一台电脑2");
              this.$Message.warning("无法远程控制同一台电脑");
              this.$store.commit("Is_MacAddress_Common", true);
              this.controlViwe_show = false; //zk128新增，同一台电脑不会显示远程组件
              this.control_type = 0; //zk新增，恢复默认值，可以再次进行远程请求
            } else {
              this.controlViwe_show = true; //zk14新增
              let type = this.$store.state.isMacAddressCommon;
              this.controlFn(type);
            }
          }
        }
        if (head.action == "1.201") {
          if (head.method == "1.1.0017") {
            this.$Message.warning(body.msg);
          }
        }
      }
    },
    // 监听联系人弹框
    modalFirst() {
      if (!this.modalFirst) {
        this.isShare = false;
        this.modalSearchValue = this.modalNameValue = ""; // 清除搜索人员的记录
        this.addUserDisabled = false; // 监听添加人员的弹框 释放禁止的点击按钮
        this.$forceUpdate();
      } else this.getTreeAndUserCategory(); // 初始化常用联系人和组织架构 只获取一次
    },
    // 监听收到的数据
    allRecords() {
      if (this.allRecords.length > 0) {
        // console.log('漫游消息进库,改为外壳处理');
        this.insertRecords();
      }
    },
    overtimeMsgKey(val) {
      //监听到超时的消息ID
      for (let i = 0; i < this.currentTempChat.length; i++) {
        for (let j = 0; j < this.currentTempChat[i].length; j++) {
          if (
            this.currentTempChat[i][j] &&
            this.currentTempChat[i][j].messageId == val
          ) {
            this.currentTempChat[i][j].isSuccessSend = 2;
            return;
          } else if (this.currentTempChat[i][j].isSuccessSend == 1) {
            this.currentTempChat[i][j].isSuccessSend = 2;
          }
        }
      }
    },
  },
  //计算computed
  computed: {
    ...mapState([
      "myInfo",
      "broadTreeList",
      "isCheck",
      "ws",
      "receiveInfo",
      "personInfoList",
      "dropDwonList",
      "sendInfo",
      "fontSetting",
      "user_hot_key",
      "messageKeyStr",
      "Version",
      "chating",
      "b4Leave",
      "defaultRemoteArr", //zk129新增
      "overtimeMsgKey",
      "authMembers", //zk0303新增，直接远程授权名单
      "isInputPWD",
      "isJoinScreen",
      "loadingShow",
      "isService",
      "icReadDriveOpen", //2022/4/15 zc新增，NFC读卡器插件是否下载
    ]),
    tableId() {
      return this.myInfo.id;
    },
    sqlTable() {
      return {
        userHotKey: `user_hot_key`,
        uninterruptedList: `uninterrupted_list_${this.tableId}`, //免打扰列表
        userInformation: `user_information_${this.tableId}`, //用户信息表
        sessionList: `session_list_${this.tableId}`, //会话列表
        broadcastList: `broadcast_list_${this.tableId}`, //广播列表
        publicList: `public_list_${this.tableId}`, //公众号列表
        groupList: `group_list_${this.tableId}`, //群列表
        messageList: `message_list_${this.tableId}`, //群聊消息表
        privateList: `private_list_${this.tableId}`, //单聊消息表
        publicRecords: `public_records_${this.tableId}`, //公众号记录表
        groupUsers: `group_users_${this.tableId}`, //	groupMessageEnity: 'GroupMessageEnity_' + this.myInfo.id,
        systemTable: `system_${this.tableId}`,
        group_message: `group_message_${this.tableId}`, //群消息
        audit_notice: `audit_notice_${this.tableId}`, //审核通知
        articleList: `article_list_${this.tableId}`, //我的文章
        collectList: `collect_list_${this.tableId}`, //我的收藏
        headPathList: `headPath_list_${this.tableId}`, //用户头像表
        updateTime: `records_updatetime_${this.tableId}`, // 消息漫游时间记录
        officialRemindList: `officialRemind_list_${this.tableId}`, //公文待办附件表
      };
    },
    iframeSrc() {
      console.log(this.myInfo, 4249);
      return (
        this.$store.state.openShareFileUrl +
        this.myInfo.shareKey +
        "&userName=" +
        this.myInfo.name +
        "&userId=" +
        this.myInfo.id +
        "&authFilesystem=" +
        (this.myInfo.authFilesystem || '')
      );
    },
    iframeOfficial() {
      return this.$store.state.openOfficialUrl + this.myInfo.id;
    },
    iframeAssetApplication() {
      return this.$store.state.assetApplicationUrl;
    },
  },
  methods: {
    getType(v) {
      console.log(v, 4130);
      this.searchType = v;
    },
    showSearchWindow() {
      console.log(777);
      this.isAssectSearchShow = true;
    },
    assectGoback(e) {
      this.workListShow(5);
    },
    viewUpdate() {
      this.$forceUpdate();
    },
    editBroadList(e) {
      this.broadList = e;
    },
    addDownloadList(item) {
      this.downloadList.push(item);
    },
    getseessionListTest(roam) {
      console.warn("漫游获取被调用了" + roam);
      if (!roam) {
        this.$Message.error("获取漫游列表失败");
      }
      roam = JSON.parse(roam);
      roam.forEach((item) => {
        let gender = 0;
        if (item.isGroup == "1") {
          gender = 1;
        } else {
          // 1男 2女
          if (item.gender == "1") {
            gender = 4;
          } else {
            gender = 5;
          }
        }
        this.messageTips(
          item.id,
          item.messageType,
          item.type,
          item.isGroup == "1" ? "" : item.head,
          item.sendName,
          gender,
          item.messageId,
          item.number
        );
      });

      this.getSessionList();
    },

    proxyFn(item) {
      let info = this.$shell("ManualUpdate", ["0"]);
      console.warn(info);
      if (info.Return_code) {
        if (!info.IsNeedUpdate) {
          this.$proxy("OpenProxy", [item.URL]);
          return;
        } else {
          this.$shell("ManualUpdate", ["1"]);
          this.$message({
            type: "success",
            message: "后台开始下载，升级中!",
          });
          this.$set(item, "NAME", "下载中");
        }
      }
    },

    // 资产弹窗
    accessWindow(name, id, token) {
      console.log(name, id, 4131);
      if (id == 59) {
        let opener = window.open(
          this.$store.state.purchaseList + `?access_token=${token}`,
          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );

        opener.document.title = name;
      } else if (id == 60) {
        let opener = window.open(
          this.$store.state.purchaseAdd + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 61) {
        let opener = window.open(
          this.$store.state.purchaseListConsumables + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 62) {
        let opener = window.open(
          this.$store.state.purchaseAddConsumables + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 63) {
        let opener = window.open(
          this.$store.state.claimantsList + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 64) {
        let opener = window.open(
          this.$store.state.claimantsAdd + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 65) {
        let opener = window.open(
          this.$store.state.transferList + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 66) {
        let opener = window.open(
          this.$store.state.transferAdd + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 67) {
        let opener = window.open(
          this.$store.state.scrapList + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 68) {
        let opener = window.open(
          this.$store.state.scrapAdd + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 69) {
        let opener = window.open(
          this.$store.state.borrowList + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      } else if (id == 70) {
        let opener = window.open(
          this.$store.state.borrowAdd + `?access_token=${token}`,

          "_blank",
          "top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1360, height=900"
        );
      }
    },
    // 自助机弹窗
    zizhujiWindow(name, staffNo, myInfo) {
      let  hasOpenCefWebForm = window.external.InvokeWinFormMethod('Internal.Function', 'hasOpenCefWebForm');
      console.log(hasOpenCefWebForm,this.$store.state.zizhujiurl + staffNo + '&employeeNo=' + myInfo.employeeno, 4480);
      //  let  formId = window.external.InvokeWinFormMethod('Form', 'getFormId');
      // if (hasOpenCefWebForm == 'TRUE') return  window.external.InvokeWinFormMethod('Internal.Function', 'openCefWebForm', '自助机管理系统',  this.$store.state.zizhujiurl,0,0,0,'');
      if (hasOpenCefWebForm == 'TRUE') return  window.external.InvokeWinFormMethod('Internal.Function', 'openCefWebForm', '自助机管理系统',  this.$store.state.zizhujiurl + staffNo + '&employeeNo=' + myInfo.employeeno,0,0,0,'');
      // if (hasOpenCefWebForm == 'TRUE') return  window.external.InvokeWinFormMethod('Internal.Function', 'openCefWebForm', '自助机管理系统','http://172.29.16.166:89/',0,0,0,'');

      let screen = window.screen
      let width = screen.availWidth
      let height = screen.availHeight
      let opener = window.open(
        this.$store.state.zizhujiurl + staffNo + '&employeeNo=' + myInfo.employeeno,
        // this.$store.state.zizhujiurl,
        "_blank",
        `top=0,left=0,toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=${width}, height=${height}`
      );

      opener.document.title = name;

      this.$store.state.autoOpeners.push(opener)

    },

    // 自助机登录
    async zizhujilogin() {
      // const res = await ntalkLogin({id:this.myInfo.id})
      // const res = await ntalkLogin({id:'10592'})

      // console.log(res,4527);
      // if (res.data.code == 200) {
      // let token = res.data.data.access_token
      // let staffNo = res.data.data.btStaff.staffNo
      // this.zizhujiWindow('自助机后台',token,staffNo)

      this.zizhujiWindow('自助机后台', this.myInfo.id,this.myInfo)

      // }else {
      //    this.$message.error("打开自助机异常");
      // }
    },
    //  资产登录授权

    async assetsLoginAuthorization(name, id) {
      let accessToken = localStorage.getItem("accessToken");
      if (accessToken) {
        this.accessWindow(name, id, accessToken);
      } else {
        this.reqLoading.state = true;
        try {
          const {
            status,
            data: { datas, resp_msg },
          } = await assetsLogin();
          this.reqLoading.state = false;
          console.log(datas, resp_msg, 4159);
          if (status == 200) {
            localStorage.setItem("accessToken", datas.access_token);

            this.accessWindow(name, id, datas.access_token);
            // if (name == "资产申请") {
            //   let opener = window.open(
            //     this.$store.state.assetApplicationUrl +
            //       `?access_token=${datas.access_token}`,
            //     "_blank",
            //     "toolbar=yes, location=yes, directories=yes, status=yse, menubar=yse, scrollbars=yes, resizable=no, copyhistory=yes, width=1207, height=637"
            //   );
            //   opener.document.title = name;
            // }

            // setTimeout(() => {
            //   let token = opener.localStorage.getItem("token");
            //   console.log(token, 4158);
            // }, 5000);
            // opener.onload = function () {
            //   console.log(opener.location.search, 4143);
            // };
          } else {
          }
        } catch (err) {
          this.reqLoading.state = false;
          this.$message.error("打开资产异常");
          console.log(err, 4112);
        }
      }
    },

    async toExamineFun(name, data, actName, index) {
      try {
        const res = await toExamine(name, data, actName);

        console.log(res, 4297);

        // if (actName == "采购受理") {
        // } else {
        if (name == "采购确认流程") {
        } else if (name == "退货流程") {
          let form = res.data.datas.data;
          this.assectForm = form[0];
        } else {
          let form = res.data.data;

          this.assectForm = form[0];
        }
        // }

        this.$nextTick(() => {
          this.workListShow(index);
        });
      } catch (error) {
        console.log(error.message, 4302);
      }
    },
    lookOffic(t, v) {
      // openOid
      if (this.$refs.offdoc) {
        this.$refs.offdoc.openOid(t, v);
      } else {
        // this.workListShow(5);
        this.openApp({ NAME: "我的待办" });
        setTimeout(() => {
          this.$refs.offdoc.openOid(t, v);
        }, 1000);
      }
    },
    openApp(item, type) {

      if (type == "accect") {
        this.assectName = item.procName;
        this.actName = item.actName;
        let actName = item.actName;
        console.log(item, 4277);
        this.instanceId = item.procInstId;
        this.$changeTitleColor("", "#fff");
        this.$set(this.siderArray[2], "active", true);

        this.workList.forEach(async (val, index) => {
          if (val.title == item.procName) {
            let access_token = localStorage.getItem("accessToken");
            if (access_token) {
              let params = {
                access_token,
                instanceId: item.procInstId,
              };
              this.toExamineFun(item.procName, params, actName, index);
            } else {
              this.reqLoading.state = true;
              try {
                const {
                  status,
                  data: { datas, resp_msg },
                } = await assetsLogin();
                this.reqLoading.state = false;
                console.log(datas, resp_msg, 4159);
                if (status == 200) {
                  localStorage.setItem("accessToken", datas.access_token);
                  let access_token = datas.access_token;
                  let params = {
                    access_token,
                    instanceId: item.procInstId,
                  };
                  this.toExamineFun(item.procName, params, actName, index);
                } else {
                }
              } catch (err) {
                this.reqLoading.state = false;
                this.$message.error("打开资产异常");
                console.log(err, 4112);
              }
            }
          }
        });
        return;
      }
      console.log(item, 5179);
      const name = item.NAME;
      if (name == "自助机后台") {
        this.zizhujilogin()
        return
      }
      const id = item.ID;
      if (
        id == "59" ||
        id == "60" ||
        id == "61" ||
        id == "62" ||
        id == "63" ||
        id == "64" ||
        id == "65" ||
        id == "70" ||
        id == "69" ||
        id == "67" ||
        id == "68" ||
        id == "66"
      ) {
        this.assetsLoginAuthorization(name, id);

        return;
      }

      //打开app
      this.$changeTitleColor("", "#fff");
      this.siderArray.forEach((val) => {
        val.active = false;
      });
      if (name == "文件传输助手") {
        this.newSearchShow = false;
        tools.operationalDatabase(
          `REPLACE INTO ${this.sqlTable.sessionList
          }(userId,isGroup,time) VALUES ('fileAssistant','0','${new Date().getTime()}');`
        );
        tools.operationalDatabase(
          `REPLACE INTO ${this.sqlTable.userInformation}(id,name,gender,account,isAdmin) VALUES ('fileAssistant','文件传输助手','2','fileAssistant',0);`
        );
        this.$changeTitleColor("#fff", "#f7f7f7");
        this.$set(this.siderArray[0], "active", true);
        let obj = {
          account: "fileAssistant",
          head: "0",
          id: "fileAssistant",
          isGroup: 0,
          name: "文件传输助手",
          userId: "fileAssistant",
          status: "1",
          gender: 2,
        };
        let flag = this.sessionList.some((val) => {
          return val.id == "fileAssistant";
        });
        if (!flag) {
          this.sessionList.unshift(obj);
        }
        this.toChat(obj);
        return false;
      }
      this.$changeTitleColor("", "#fff");
      this.$set(this.siderArray[2], "active", true);
      console.log(this.workList, 4126);
      this.workList.forEach((val, index) => {
        if (val.title == name) {
          this.workListShow(index);
        }
      });
    },

    replaceTosymbol(i) {
      let a = i.replace(/<[^>]+>/g, "");
      return a;
    },

    toPreviewFile(item, type) {
      //zk0202新增，已下载文件的预览
      let isDownload =
        item.isDownLoad ||
        JSON.parse(item.VALUE).fileName ||
        JSON.parse(item.VALUE).isDownLoad;
      if (type == 1) {
        //zk0204新增，type = 1是收藏视频预览
        console.log(item, "点击的那条收藏");
        let tableName =
          item.TYPE == "1"
            ? this.sqlTable.messageList
            : this.sqlTable.privateList;
        console.log(tableName, item.MESSAGE_ID);
        let result = tools.operationalDatabase(
          `SELECT isDownLoad FROM ${tableName} WHERE messageId='${item.MESSAGE_ID}';`,
          1
        );
        if (result.list[0] && result.list[0].length > 0)
          isDownload = result.list[0].isDownLoad;
        console.log(result, isDownload, "查询结果，路径");
      }
      let rep = this.$shell("OpenFlieByUrl", [
        this.$isRelativePath(isDownload),
      ]);
      rep = JSON.parse(rep);
      if (rep.return_code == "FALSE") {
        this.$Message.info("系统找不到指定的文件,请重新下载");
        this.$set(item, "isDownLoad", 0);
        return;
      }
    },
    toNewVersion() {
      //zk129新增，更新程序
      let info = this.$shell("ManualUpdate", ["1"]);
      this.$refs.tipButton.innerHTML = "更新中，请稍后...";
      console.log(info, "更新&重启", this.$refs.tipButton);
    },
    //更新列表用户状态
    updateSessionListStatus(ids) {
      getUsersStatus({ ids: ids }).then((data) => {
        if (data.result == "200") {
          for (let i in data.data) {
            if (data.data[i].id == this.toInfo.id) {
              this.$store.commit("Sync_User_Status", data.data[i].status);
            }
          }
          for (let i in this.sessionList) {
            for (let j in data.data) {
              if (this.sessionList[i].id == data.data[j].id) {
                this.sessionList[i]["status"] = data.data[j].status;
                this.$store.commit(
                  "updatedNowMsgUserState",
                  this.sessionList[i]
                );
              }
            }
          }
        }
      });
    },
    showRecords(flag, info) {
      //zk120
      if (flag) {
        //打开时同时获取数据
        this.recordList = [];
        this.recordId = info.messageId;
        console.log(info, "点击的那条历史记录的详情");
        // let id = info.id;
        let id;
        id = info.isGroup == 1 ? info.id : this.staticArray.id;
        let isTrue = info.isGroup == "1";
        var str;
        str = `${isTrue ? this.sqlTable.messageList : this.sqlTable.privateList
          } a left join ${this.sqlTable.userInformation
          } b on a.sendId=b.id WHERE (${isTrue
            ? `a.receiveId='${id}'`
            : `a.sendId='${id}' OR a.receiveId='${id}'`
          })`;
        let res = tools.operationalDatabase(
          `SELECT a.*,b.head FROM  ${str} ORDER BY time DESC;`,
          1
        );
        let len = res.list.length;
        for (let i = 0, len = res.list.length; i < len; i++) {
          res.list[i].value = this.setHistoryMsg(res.list[i]);
        }
        this.recordList = res.list;
      }
      this.detailShow = flag;
      this.recordshow = flag;
      this.search_broad_show_item = false;
      this.searchTargetShow = false;
      // this.$$nextTick(()=>{
      this.$refs.recordDetail.getRecord();
      // })
    },
    detailClick() {
      this.searchFocus();
      this.timeShow = false;
    },
    toDetail(temp) {
      //zk118新增，显示详情
      this.detailShow = true;
      this.detailArray = { ...temp };
      this.staticArray = { ...temp };
      this.searchStartTime = "";
      this.searchEndTime = "";
      this.timeShow = false;
      let value = this.searchArray[0]; //初始的关键字
      this.searchArray = [value]; //针对再搜索之后切换搜索结果显示不相干词条
      this.showRecords(true, this.detailArray.data[0]);
      console.log(temp, "展示详情");
    },
    setSearchArray(value, flag, action) {
      //zk119新增，修改searchArray,flag为true表示是session栏搜索，每次清空array，为false就是再搜索，直接push,action为1表示新增，2表示删除
      if (flag) {
        this.searchArray = [];
      }
      let arr = this.searchArray;
      if (arr.indexOf(value) == -1 && action == 1) {
        this.searchArray.push(value);
      } else if (action == 2) {
        arr = arr.filter((item) => {
          return item != value;
        });
        this.searchArray = arr;
      }

      let starttime = this.searchStartTime
        ? new Date(this.searchStartTime).getTime()
        : "";
      let endTime = this.searchEndTime
        ? new Date(this.searchEndTime).getTime()
        : "";

      let newArr = this.staticArray.data || []; //针对filter报错
      let regstr = "";
      // let reg = /(?=.*ab+).*(?=.*bc+).*/   //ab,bc出现一次或多次且不分顺序
      arr.forEach((item) => {
        regstr += `(?=.*${item}+).*`;
      });
      let reg = new RegExp(regstr, "i");
      if (starttime) {
        newArr = newArr.filter((item) => {
          //开始时区
          return starttime < item.time;
        });
      }
      if (endTime) {
        newArr = newArr.filter((item) => {
          //结束时区
          return endTime > item.time;
        });
      }
      newArr = newArr.filter((item) => {
        //关键字
        return reg.test(item.value);
      });
      this.$set(this.detailArray, "data", newArr);
    },
    // 同屏邀请
    getPersonFn(obj) {
      this.checkPersonArray = [...obj.list]; //zk0531修改,解除两个数组的强关联,防止互相影响
      this.screenFlag = obj;
      this.isUpdateUser = false;
      this.setModalFirst(9);
    },
    // 重置全局结束同屏参数
    globalOverScreenFn() {
      this.globalOverScreen = false;
      this.screenPersonList = [];
    },
    initIsAutoOpenScreen() {
      this.isAutoOpenScreen = false;
    },
    addRemoteMember(groupId) {
      console.log(groupId);
      this.currentRemoteGroup = groupId;
      this.setModalFirst(9);
    },
    getDefaultRemoteArr() {
      //zk129新增,获取默认的可远程人员，created中调用
      findGroup({ userId: this.myInfo.id }).then((res) => {
        if (res.resp_code == 0) {
          console.log(res.resp_msg, res.datas);
          this.setDefaultRemote(res.datas);
        }
      });
    },
    toRawStr(value) {
      //zk新增，将待办的value换成纯文本
      let str = value
        .replace(/<br>/g, "")
        .replace(/&lt;/g, "<")
        .replace(/&nbsp;/g, " ")
        .replace(/&amp;/g, "&");
      return str;
    },
    // 新增我的待办筛选
    screenRemind() {
      let remindListN = this.remindList.filter((item) => item.ISDONE == 0); // 待办
      let remindListY = this.remindList.filter((item) => item.ISDONE == 1); // 已完成
      this.remindOfficialListSortList(remindListN);
      this.remindOfficialListSortList(remindListY);
      if (this.processedTypeSel == 0) {
        // 全部
        if (this.processedTypeSelAdd == 0) {
          this.remindOfficialList = this.remindOfficialListArr;
        } else if (this.processedTypeSelAdd == 1) {
          this.remindOfficialList = [...this.notDataList, ...remindListN];
          this.remindOfficialListSortList(this.remindOfficialList);
        } else if (this.processedTypeSelAdd == 2) {
          this.remindOfficialList = [...this.dataList, ...remindListY];
          this.remindOfficialListSortList(this.remindOfficialList);
        }
      } else if (this.processedTypeSel == 1) {
        // 日程提醒
        if (this.processedTypeSelAdd == 0) {
          this.remindOfficialList = this.remindList;
        } else if (this.processedTypeSelAdd == 1) {
          this.remindOfficialList = remindListN;
        } else if (this.processedTypeSelAdd == 2) {
          this.remindOfficialList = remindListY;
        }
      } else if (this.processedTypeSel == 2) {
        // 公文
        if (this.processedTypeSelAdd == 0) {
          this.remindOfficialList = [...this.notDataList, ...this.dataList];
        } else if (this.processedTypeSelAdd == 1) {
          this.remindOfficialList = this.notDataList;
        } else if (this.processedTypeSelAdd == 2) {
          this.remindOfficialList = this.dataList;
        }
      }
      // 即时通讯待办创建时间过滤
      if (this.remindOfficialTimeDispose) {
        let viewStartTime = this.$formatDateTime(
          new Date(this.remindOfficialTimeDispose[0])
        );
        let viewEndTime = this.$formatDateTime(
          new Date(this.remindOfficialTimeDispose[1])
        );
        let remindList = this.remindOfficialList.filter((item) => item.ISDONE);
        let officialList = this.remindOfficialList.filter(
          (item) => !item.ISDONE
        );
        let newRemindList = remindList.filter(
          (item) =>
            new Date(item.REMIND_TIME).getTime() >=
            new Date(viewStartTime).getTime() &&
            new Date(item.REMIND_TIME).getTime() <=
            new Date(viewEndTime).getTime()
        );
        // 排序
        let nNewRemindList = this.remindOfficialListSortList(
          newRemindList.filter((item) => item.ISDONE == 0)
        );
        let yNewRemindList = this.remindOfficialListSortList(
          newRemindList.filter((item) => item.ISDONE == 1)
        );
        let nOfficialList = this.remindOfficialListSortList(
          officialList.filter((item) => !item.isManage)
        );
        let yOfficialList = this.remindOfficialListSortList(
          officialList.filter((item) => item.isManage)
        );
        this.remindOfficialList = [
          ...nNewRemindList,
          ...nOfficialList,
          ...yNewRemindList,
          ...yOfficialList,
        ];
      }
    },
    ...mapMutations([
      "setChating",
      "setb4Leave",
      "setDefaultRemote",
      "setAuthMembers",
    ]),
    changeShow(data, flag) {
      //zk新增，封装针对修改true/false属性的父组件方法,第一个参数为属性名，第二个为要修改的值，没有参数默认取反
      if (flag != undefined) {
        //有传值过来
        this[data] = flag;
      } else {
        this[data] = !this[data];
      }
    },
    changeProp(id, path, type) {
      //zk新增，修改chatlist和currenttempchat的属性值，type表示要修改哪条，small表示smallValue，raw表示rawValue
      for (let i in this.currentTempChat) {
        for (let j in this.currentTempChat[i]) {
          if (id == this.currentTempChat[i][j].messageId) {
            switch (type) {
              case "small":
                this.$set(this.currentTempChat[i][j], "smallValue", path);
                break;
              case "raw":
                this.$set(this.currentTempChat[i][j], "rawValue", path);
                break;
              case "value":
                this.$set(this.currentTempChat[i][j], "value", path);
                break;
              case "isDownLoad":
                this.$set(this.currentTempChat[i][j], "isDownLoad", path);
                break;
              default:
                console.log("错误方法-----", type);
            }
          }
        }
      }
      //同时修改chatlist，防止翻页时取不到smallvalue的值导致的重复下载
      for (let i in this.chatList) {
        for (let j in this.chatList[i]) {
          if (id == this.chatList[i][j].messageId) {
            switch (type) {
              case "small":
                this.$set(this.chatList[i][j], "smallValue", path);
                break;
              case "raw":
                this.$set(this.chatList[i][j], "rawValue", path);
                break;
              case "value":
                this.$set(this.chatList[i][j], "value", path);
                break;
              case "isDownLoad":
                this.$set(this.chatList[i][j], "isDownLoad", path);
                break;
              default:
                console.log("错误方法-----", type);
            }
          }
        }
      }
    },
    isInArr(id, arr) {
      //zk新增，判断messageid是否在chatlist中，不存在就继续查chatlist，存在就返回chatlist
      let result = arr.find((obj) => {
        return obj.messageId == id;
      });
      if (result == undefined) {
        this.messageScrollChange(); //调函数往后取20条
        let newArr = this.chatList[0].concat(this.chatList[1]);
        this.isInArr(id, newArr); //递归调检查是否包含该元素
      } else {
        let newArr = this.chatList[0].concat(this.chatList[1]);
        this.containArr = [...newArr];
        return newArr;
      }
    },
    switchChatMain(messageId) {
      this.firstUnreadId = "";
      //zk新增，选中历史消息之后聊天框跳转过去,倒序查找
      this.currentNewsId = messageId;
      let newArr = this.chatList[0].concat(this.chatList[1]);
      console.log(this.chatList[1]);
      this.isInArr(messageId, newArr); //获取到包含该messageid的chatlist
      newArr = [...this.containArr];
      let maxlength = newArr.length;
      let count = 0;
      let flag = false; //开始存入标志符
      let totalRest = this.readNumber * 2; //消息记录距最新消息是否够20条，不够就用历史消息补齐，默认够20条
      this.currentTempChat = [[], []];
      let once = true; //变量，总长不足20，总长超过20但该条距最新不足20，该标记确保数据只会插入一次
      for (let i = maxlength - 1; i >= 0; i--) {
        if (messageId == newArr[i].messageId) {
          flag = true;
          totalRest = i + 1; //该条记录到最新消息之间有几条（包括该条）
          console.log(totalRest, "该条距最新一条之间有多少条");
        }
        if (
          maxlength <= this.readNumber * 2 ||
          (maxlength > this.readNumber * 2 && totalRest < this.readNumber * 2)
        ) {
          //全部聊天不超过10条，全部渲染，或，超过10条但该条消息到最新消息不足10条，需用历史消息补齐，127注释，此时需chatList正序渲染
          if (once) {
            for (let i = 0; i < maxlength; i++) {
              if (count < this.readNumber) {
                this.currentTempChat[0].unshift(newArr[i]);
                count++;
              } else if (count < this.readNumber * 2) {
                this.currentTempChat[1].push(newArr[i]);
                count++;
              }
            }
          }
          once = false;
          this.havenext = false; //不足10条，不可以往下划
        } else {
          //该条消息到最新消息超过10条,则从该条到最新消息渲染10条
          //0新增消息用的push,1取历史消息用的unshift，当时这么处理时为了解决收发消息时头像闪动的问题
          if (flag && count < this.readNumber) {
            this.currentTempChat[1].unshift(newArr[i]);
            count++;
          } else if (flag && count < this.readNumber * 2) {
            this.currentTempChat[0].push(newArr[i]); //zk修改，unshift改为push
            count++;
          }
          this.havenext = true; //超过了10条，肯定可以往下划
        }
      }
      this.$nextTick(() => {
        this.$refs.homeChatMain.fixedPosition(messageId, "start");
      });
    },
    getTop() {
      //zk新增，到顶之后，修改currentTempChat
      let temArr = this.chatList[0].concat(this.chatList[1]);
      let length = temArr.length;
      if (length < this.readNumber * 2) {
        //第一次不足十条，不进行替换
        this.havePre = false;
      }
      if (this.havePre) {
        let lengthOfTemp1 = this.currentTempChat[1].length;
        let id = this.currentTempChat[1][lengthOfTemp1 - 1].messageId; //上次的从chatlist查找的最后一条的id
        // this.currentTempChat[0] = this.currentTempChat[1]//把0里面的值移到1
        // //0往后再找5条,messageId
        // this.currentTempChat[1] = [];

        let temp = this.currentTempChat[1].reverse();
        this.$set(this.currentTempChat, 0, temp);
        this.$set(this.currentTempChat, 1, []);

        let flag = false;
        let count = 0;
        for (let i in this.chatList) {
          for (let j in this.chatList[i]) {
            if (id == this.chatList[i][j].messageId) {
              //找到最后一条的位置，往后五条插入0中
              flag = true;
            }
            if (
              flag &&
              count < this.readNumber &&
              id != this.chatList[i][j].messageId
            ) {
              this.currentTempChat[1].push(this.chatList[i][j]);
              count++;
            }
          }
        }
        this.havenext = true; //往上划过，肯定可以往下划
      } else {
        // this.$Message.warning('到顶了！');
      }
      if (this.currentTempChat[1].length < this.readNumber) {
        //表示最后一次查找不足五条，表里没有了
        this.havePre = false;
      }
      console.log(this.currentTempChat, "上划之后的temp");
    },
    getBottom() {
      //zk新增，到底了
      console.log("触发了到底函数", this.havenext);
      let newArr = this.chatList[0].concat(this.chatList[1]);
      console.log(newArr, 5164);
      if (this.havenext) {
        let length = this.currentTempChat[0].length;
        let id = this.currentTempChat[0][length - 1].messageId; //上次的从chatlist查找的最后一条的id
        // this.currentTempChat[1] = this.currentTempChat[0]//把0里面的值移到1
        // this.currentTempChat[0] = [];
        let temp = this.currentTempChat[0].reverse();
        this.$set(this.currentTempChat, 1, temp);
        this.$set(this.currentTempChat, 0, []);
        let flag = false;
        let count = 0;
        for (let i = newArr.length - 1; i >= 0; i--) {
          if (id == newArr[i].messageId) {
            flag = true;
          }
          if (flag && count < this.readNumber && id != newArr[i].messageId) {
            this.currentTempChat[0].push(newArr[i]);
            count++;
          }
        }

        console.log(this.currentTempChat[0], count, 5185);
      } else {
        // this.$Message.warning('到底了！');
      }
      for (let j in this.currentTempChat[0]) {
        if (this.currentTempChat[0][j].messageId == newArr[0].messageId) {
          //temp0里已经有了第一条聊天的记录，表示已经到底了
          this.havenext = false;
        }
      }
      this.havePre = true; //往下划过，肯定可以往上划
      console.log(this.currentTempChat, "下滑之后的temp");
    },
    resetUp_DownFlag() {
      //zk新增，重置翻页标志
      this.havePre = true;
      this.havenext = false;
    },
    changeActive(index) {
      //zk修改激活状态
      if (index == "0") {
        this.readView(this.currentItem.readData, index, {});
      } else {
        this.readView(this.currentItem.downloadData, index, {});
      }
    },
    //index --->1为搜索,其他不需要参数
    operationalFromDatabase(statements, index) {
      let to = JSON.stringify({
        Sqlstr: statements,
      });
      return arguments[1]
        ? JSON.parse(this.$shellSQL(to, index))
        : JSON.parse(this.$shellSQL(to));
    },
    // 获取最后的更新时间
    getLastUpdateTime(id) {
      let tableName = `records_updatetime_${this.myInfo.id}`;
      return this.operationalFromDatabase(
        `SELECT * FROM ${tableName} WHERE account='${this.myInfo.id}';`,
        1
      );
    },
    // 同步漫游消息
    getHistoryMsg() {
      // 个人用户信息
      let info = this.myInfo;
      // 判断权限
      if (info.roam != 1) {
        return;
      }
      // 默认分页设置
      let page = {
        pageSize: "10000",
        pageNumber: "1",
      };
      // 获取本地库的时间
      let startDate = "";
      let endDate = this.$utilJs.getDating();
      // 获取上一次拉取数据的时间
      let res = this.getLastUpdateTime();
      // 如果拉取成功则更新时间
      if (res.success) {
        if (res.list.length) {
          startDate = res.list[0].updateTime;
        } else {
          // 在本地数据库插入该用户拉取数据更新的时间
          this.operationalFromDatabase(
            `INSERT INTO records_updatetime_${info.id} (account,updateTime) VALUES ('${info.id}','${endDate}');`
          );
        }
      }
      // 在本地数据库更新拉取数据时间
      this.operationalFromDatabase(
        `UPDATE records_updatetime_${info.id} SET updateTime = '${endDate}' WHERE account = '${info.id}'`
      );

      let chatQuery = startDate ? { startDate, endDate } : {};
      this.ws.send(
        this.$publicSend(info.head, "1.500", "1.1.1004", {
          sendUserId: info.id,
          page,
          chatQuery,
        })
      );
    },

    // 插入历史消息记录，漫游消息进库
    insertRecords() {
      let arr = this.allRecords;
      let sqlArr = [];
      arr.map((con, index) => {
        let val = con.content.sections[0].items[0];
        if (val.value) {
          let messageId = con.messageKey;
          let time = con.content.timestamp;
          let sendId = con.sendUserData.id;
          let receiveId = con.receiveUserData.id;
          let name = JSON.parse(val.value).sendName;
          let gender = JSON.parse(val.value).gender;
          let head = JSON.parse(val.value).head;
          let fontSize = JSON.parse(val.value).fontSize;
          let isRead = 1;
          let isSuccessSend = 0;
          let isDownLoad = "Message-roaming";
          let duration = type == "text" ? 32 : JSON.parse(val.value).size;
          let isByRead = 1;
          let type = val.type;
          let DownLoadId = type == "text" ? "0" : JSON.parse(val.value).id;
          // let value =
          //   (type == "text" || type == "GPS" || type == "shareGroup" || type == "revocation")
          //     ? JSON.parse(val.value).text
          //     : JSON.parse(val.value).name;
          //zk1224修改，type为gps，shareGroup和"revocation"时也取text,replace针对对象存入时的转义字符
          let value =
            type == "text" ||
              type == "GPS" ||
              type == "shareGroup" ||
              type == "revocation"
              ? type == "GPS" || type == "shareGroup"
                ? // ? type == "GPS"?'"'+JSON.parse(val.value).text.replace(/\"/g,'\\\"')+'"':JSON.parse(val.value).text
                JSON.stringify(JSON.parse(JSON.parse(val.value).text))
                : JSON.parse(val.value).text
              : JSON.parse(val.value).name;
          if (type == "GPS" || type == "shareGroup") {
            //console.log(value);
          }
          let sql = {
            Sqlstr: `insert into private_list_${this.myInfo.id}(name,receiveId,sendId,type,value,time,messageId,isRead,isSuccessSend,isDownLoad,DownLoadId,duration,isByRead,fontSize) select "${name}", "${receiveId}", "${sendId}","${type}", "${value}", "${time}", "${messageId}","${isRead}","${isSuccessSend}","${isDownLoad}","${DownLoadId}", "${duration}", "${isByRead}","${fontSize}" where not exists (select 1 from private_list_${this.myInfo.id} where messageId = "${messageId}");`,
          };
          sqlArr.push(sql);
        }
      });
      let sqlJSon = {
        SqlList: sqlArr,
      };
      this.$shellSQLIST(JSON.stringify(sqlJSon));
    },
    getRightMenu({ $event, item, top, left }) {
      this.groupInfo = item;
      this.rightShow = false;
      this.getRightMenuPosition.x = top;
      this.getRightMenuPosition.y = left;
      this.rightShow = true;
    },
    addGrounpMengers() {
      // console.log(this.groupInfo);
      // ***********************************************
      let arr = [];
      arr.push({
        type: this.groupInfo.FID ? "1" : "0",
        value: this.groupInfo.FID,
      });
      let groupName = this.groupInfo.LEABLE + "群聊";
      addGroup({
        userid: this.myInfo.id,
        name: groupName,
        introduce: "",
        members: JSON.stringify(arr),
      })
        .then((res) => {
          if (res.result == 200) {
            this.getGroupUser();
            this.rightShow = false;
            this.$Message.success("创建成功");
          } else if (res.result == 4) {
            this.$Message.warning("系统错误");
          } else if (res.result == 2) {
            this.$Message.warning("无权限");
          }
        })
        .catch((error) => {
          this.addUserDisabled = false;
        });
      // ***********************************************
    },
    cancelAddGrounpMengers() {
      this.groupInfo = null;
      this.rightShow = false;
      this.getRightMenuPosition.x = 0;
      this.getRightMenuPosition.y = 0;
    },
    // 系统升级 关闭程序后自动重启

    // 计算分页
    getPageNum(num) {
      if (num <= 0) {
        this.page_num = 1;
        return;
      }
      let maxcount = Math.ceil(num / this.pageSize);
      if (this.page_num >= maxcount) {
        this.page_num = parseInt(maxcount);
      } else if (this.page_num <= 0) {
        this.page_num = 1;
      } else {
        this.page_num = parseInt(this.page_num);
      }
    },
    // 初始化分页
    initPage() {
      this.page_num = 1;
      this.files_cur = 1;

      this.$nextTick(() => {
        if (this.workList[1].show)
          this.$refs.myBroadcastnotification.broadSearchFn();
        if (this.workList[7].show) this.$refs.myArticle.articleSearchFn();
        if (this.workList[4].show) this.$refs.isMycollection.collectSearchFn();
      });
    },

    // 强制刷新页面
    pageForceUpdate() {
      this.pageFlagShow = false;
      this.$nextTick(() => {
        this.pageFlagShow = true;
      });
    },
    // 强制刷新广播详情页面
    broadForceUpdate() {
      this.broadFlagShow = false;
      this.$nextTick(() => {
        this.broadFlagShow = true;
      });
    },
    broadListForceUpdate() {
      this.broadListFlagShow = false;
      this.$nextTick(() => {
        this.broadListFlagShow = true;
      });
    },
    goPage() {
      this.files_cur = parseInt(this.page_num);
      // 新增广播分页
      // if (this.workList[1].show)  this.$refs.myBroadcastnotification.broadSearchFn()
      // 新增文章分页
      if (this.workList[7].show) this.$refs.myArticle.articleSearchFn();
      // 新增我的收藏分页
      // if (this.workList[4].show) this.collectSearchFn();
      this.$forceUpdate();
    },
    pageChange(index) {
      console.log(index, 4848);
      this.files_cur = index;
      // 新增广播分页
      // if (this.workList[1].show) this.broadSearchFn();
      // 新增文章分页
      this.$nextTick(() => {
        if (this.workList[7].show) this.$refs.myArticle.articleSearchFn();
      });
      // 新增我的收藏分页
      // if (this.workList[4].show) this.collectSearchFn();
    },
    chatingFun(msg) {
      // this.chating = msg;//zk注释
      this.setChating(msg);
      this.setb4Leave(msg);
    },
    dbNewChat(item, bol) {
      //我的部门/组织架构双击
      if (this.clickIntervale) {
        window.clearTimeout(this.clickIntervale);
        this.clickIntervale = null;
      }
      //判断会话列表是否存在当前联系人会话，存在就切掉继续跳转
      for (let i in this.sessionList) {
        if (item.id == this.sessionList[i].id) {
          this.sessionList.splice(i, 1);
          break;
        }
      }
      //判断双击是否点击的是目录
      if (item.CN != null) return;
      //不能和自己聊天
      if (
        this.myInfo.id == item.ID ||
        this.myInfo.id == item.id ||
        this.myInfo.id == item.NO
      )
        return;
      this.toNewChat(item, bol);
      this.dbtoNewChat(item, bol);
    },
    setSendHot(val) {
      this.senHot = val;
    },
    openInstantSharing() {
      let res = this.$shell("OpenBrowser", [
        this.$store.state.InstantSharingUrl,
      ]);
    },
    pushPlayerOptions(messageId, isDownLoad) {
      this.playerOptions[messageId] = {
        playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
        autoplay: false, //如果true,浏览器准备好时开始回放。
        muted: false, // 默认情况下将会消除任何音频。
        loop: false, // 导致视频一结束就重新开始。
        preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
        language: "zh-CN",
        aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
        fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
        sources: [
          {
            type: "",
            src: this.$isRelativePath(isDownLoad), //视频url地址
          },
        ],
        poster: "", //你的封面地址
        // width: document.documentElement.clientWidth,
        notSupportedMessage: "此视频暂无法播放，请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
        controlBar: {
          timeDivider: true,
          durationDisplay: true,
          remainingTimeDisplay: false,
          fullscreenToggle: true, //全屏按钮
        },
      };
    },
    updateChatList(value) {
      // this.chatList[0].unshift(value);//zk注释，vue页面刷新机制，无法改动新增消息头像闪动问题
      if (value.sendId == this.myInfo.id) {
        value.isServiceAcc = this.isService ? 1 : 0;
      }

      this.chatList[0].unshift(value); //新消息往list0里push
      if (!this.havenext) {
        //只有当前显示聊天内容到达底部，才会往temp中push

        console.log(JSON.parse(JSON.stringify(value)), 4878);
        this.currentTempChat[0].push(value); //新消息往tempchat0里push
        console.log([JSON.parse(JSON.stringify(this.currentTempChat)),this.currentTempChat], '发送前本地添加消息');
      }

      console.log(value, "聊天记录表更新");
    },
    // 新增消息发送text image( 已经转移到updateFileStatus )就存储到数据库
    storageSqlSendText(data) {
      // 0未读 1已读
      let isRead = 0
      if (data.isGroup == "1") {
        isRead =
          data.receiveId == this.toInfo.id || data.sendId == this.myInfo.id
            ? 1
            : 0;
      } else {
        isRead =
          data.sendId == this.toInfo.id || data.sendId == this.myInfo.id
            ? 1
            : 0;
      }
      if (data.type == "text") {
        // console.log(data.isServiceAcc, 4863);
        this.insertData(
          data.sendName,
          data.receiveId,
          data.sendId,
          data.type,
          data.value,
          data.time,
          data.messageId,
          isRead,
          "1",
          "0",
          "0",
          -1,
          data.isGroup,
          data.fontSize,
          data.headUrl,
          data.replay,
          data.isServiceAcc
        );
        this.updateSessionChat(
          data.sendId,
          data.receiveId,
          data.sendName,
          data.receiveName,
          data.value,
          data.time,
          data.isGroup,
          data.messageId,
          data.type,
          0,
          0,
          0,
          data.replay,
          data.fontSize
        );
      }
    },
    updateDropState(state) {
      this.isOndropHandle = state;
    },
    newSessionSort() {
      this.sortSessionList();
      this.$nextTick(()=>{
        if(this.$refs['homeChatMain']){
          this.$refs['homeChatMain'].scrollToLower()
        }
      })
    },

    // 删除群公告
    delNoticeShow(item) {
      console.log(item,'群公告列表');
      this.curNotice = item;
      this.noticeConfirm = true;
    },
    // 删除群公告
    deleteNotice() {
      delGroupPublicNoticesBatch({
        groupid: this.toInfo.id,
        userid: this.myInfo.id,
        noticeid: this.curNotice.ID,
      })
        .then((res) => {
          if (res.result == 200) {
            for (let i = 0; i < this.groupNoticeList.length; i++) {
              if (this.groupNoticeList[i].ID == this.curNotice.ID) {
                this.groupNoticeList.splice(i, 1);
              }
            }
            // let tableName =
            //   this.toInfo.isGroup == "1"
            //     ? this.sqlTable.messageList
            //     : this.sqlTable.privateList;
            // let result = tools.operationalDatabase(
            //   `DELETE FROM ${tableName} WHERE messageId='${item.messageId}';`
            // );
            this.$Message.success("删除公告成功");
          } else {
            this.$Message.success(res.msg);
          }
          this.noticeConfirm = false;
        })
        .catch((res) => {
          this.noticeConfirm = false;
          this.$Message.success("服务器出错,稍后再试2");
        });
    },
    getGroupInfo(info) {
      this.shareGroupInfo = info;
      this.showJoinGroup = true;
    },
    confirmJoinGroup() {
      //判断是否再群聊中
      let shareGroupId = this.shareGroupInfo.value.shareGroupId;
      let initid = this.$func.uuid();
      let flag = true;
      getGroupByUserId({ userid: this.myInfo.id }).then((res) => {
        if (res.result === 200) {
          for (let i in res.data) {
            if (res.data[i].id == shareGroupId) {
              this.$Message.warning("你已加入当前群聊，无法重复申请");
              flag = false;
              return;
            }
          }
          //判断是否再审核中
          if (flag) {
            let msg = this.$store.state.groupCheck || {};
            if (msg.result == 200 && msg.status) {
              this.$Message.warning("审核中，请勿重复申请");
              return;
            }
            this.ws.send(
              this.$publicSend(initid, "1.201", "1.1.0017", {
                userId: this.myInfo.id,
                groupid: this.shareGroupInfo.value.shareGroupId,
                members: this.shareGroupInfo.sendId,
                userName: this.myInfo.name,
                groupName: this.shareGroupInfo.value.shareGroupName,
                head: this.myInfo.head,
                department: this.myInfo.departmentname,
                shareName: this.shareGroupInfo.name,
                applyJobTitle: this.myInfo.jobtitle,
                applyGender: this.myInfo.gender,
                introduce: "",
              })
            );
            this.$Message.success("申请入群成功,请等待审批");
          }
        }
      });
      // this.ws.send(this.$publicSend(initid,'1.201','1.1.0017',{userId:this.myInfo.id,groupid:this.shareGroupInfo.value.shareGroupId,members:this.shareGroupInfo.sendId,userName:this.myInfo.name,groupName:this.shareGroupInfo.value.shareGroupName,head:this.myInfo.head,department:this.myInfo.departmentname,shareName:this.shareGroupInfo.name,applyJobTitle:this.myInfo.jobtitle,applyGender:this.myInfo.gender,introduce:""}));
      // this.$Message.success('申请入群成功,请等待审批');
      this.showJoinGroup = false;
    },
    //邀请入群，zk1215标识，群分享
    shareCode(obj) {
      this.isShare = obj.isShare;
      // 初始化群成员id数组
      this.shareChoosed = [];
      this.group_detail.users.map((temp) => {
        this.shareChoosed.push(temp.ID || temp.id);
      });
      let toInfo = JSON.parse(JSON.stringify(this.toInfo));
      this.shareInfo = {
        shareGroupId: toInfo.id,
        shareGroupName: toInfo.name,
        shareId: this.myInfo.id,
        shareName: this.myInfo.name,
        applyJobTile: this.myInfo.jobtitle,
        applyGender: this.myInfo.gender,
        introduce: obj.introduce,
      };
      this.setModalFirst(6);
    },
    copyShowClick(bol) {
      this.copyShow = bol;
    },
    calendar_close() {
      this.editFlag = true; //zk新增，编辑框隐藏之后，编辑按钮可用
      this.participant = [];
      this.resetModalFirst();
      this.$refs.newCalendar.scheduleAugumentsInit();
      this.newCalendarShow = false;
      this.$forceUpdate();
    },

    delMemberViewActive(bol) {
      this.delMemberView = bol;
    },
    //显示隐藏聊天消息右键方法
    chatFunctionHandle(active) {
      this.chatFunctionActive = active;
    },
    //更新联系人推送状态
    refStatus(body) {
      console.log(
        body.status,
        body.userId,
        this.$getingTime(),
        "用户状态更改=>"
      );
      // 为解决父组件更新数据子组件无法更新视图的问题
      this.$store.commit("Update_User_Status", body);
      // 我
      if (body.userId == this.toInfo.id) {
        this.toInfo.status = body.status;
      }
      // 会话列表
      for (let i = 0; i < this.sessionList.length; i++) {
        if (this.sessionList[i].id == body.userId) {
          this.sessionList[i].status = null;
          this.sessionList[i].status = body.status;
        }
      }
      // 常用联系人
      for (let i = 0; i < this.friendsGroup.length; i++) {
        for (let j = 0; j < this.friendsGroup[i].USER.length; j++) {
          if (body.userId == this.friendsGroup[i].USER[j].ID) {
            this.friendsGroup[i].USER[j].status = body.status;
          }
        }
        this.friendsGroup[i].USER.sort(this.$personStatusSort("status"));
      }
      // 我的部门
      for (let item of this.bookList[3].myDepartment) {
        for (let temp of item.ARR) {
          if (temp.ID == body.userId) {
            temp.status = body.status;
          }
        }
        let CNARR = item.ARR.filter((item) => item.CN);
        let STATUSARR = item.ARR.filter((item) => item.status).sort(
          this.$personStatusSort("status")
        );
        item.ARR = [...STATUSARR, ...CNARR];
      }
    },
    forwardMore() {
      if (this.chatChooseList.length <= 0) {
        this.$Message.warning("请选择要转发的内容");
        return;
      }
      if (this.modalTitle != 2) {
        this.resetModalFirst();
      }
      // this.isForwardMore=true;
      this.modalTitle = 2;
      this.modalFirst = true;
    },

    setchatChooseList(val) {
      this.chatChooseList = val;
    },
    // 重置多选
    resetChatChoose() {
      for (let i in this.chatList) {
        for (let j in this.chatList[i]) {
          this.$set(this.chatList[i][j], "isChoose", false);
        }
      }
    },
    multiSelectClick() {
      this.isMultiSelect = true;
      this.chatChooseList = [];
      this.resetChatChoose();
    },
    setChatList(value) {
      this.chatList = value;
    },
    //下载文件列表添加任务
    downloadListAddProcess(item) {
      console.log(item, 5252);
      this.downloadList.push(item || []);
    },
    // 公文附件存储到本地数据库
    setOfficialFileSQL(arr) {
      this.downLoadFileList = [];
      arr.map((item) => {
        this.$ajax_official(
          "get",
          `office/document/files/findOne/${item}`,
          {},
          (res) => {
            if (res.code == 200) {
              // 公文附件存储到本地数据库
              let officialRemindList = `officialRemind_list_${this.$store.state.myInfo.id}`;
              let isExist = tools.operationalDatabase(
                `SELECT FILE_ID,LOCAL_PATH FROM ${officialRemindList} WHERE FILE_ID = '${item}'`,
                1
              );
              if (isExist && isExist.list && isExist.list.length == 0) {
                tools.operationalDatabase(
                  `REPLACE INTO ${officialRemindList}(FILE_SORECE,FILE_ID,FILE_NAME,LOCAL_PATH,LOAD_URL,CREATE_TIME) VALUES ('01','${item}','${res.data.fileName
                  }','','${this.$store.state.url_official +
                  `office/out/downLoad/${item}`
                  }','${new Date().getTime()}')`
                );
              }
              this.downLoadFileList.push({
                id: item,
                name: res.data.fileName,
                size: this.$formatSize(res.data.fileSize),
                filePath:
                  isExist && isExist.list && isExist.list.length
                    ? isExist.list[0].LOCAL_PATH
                    : "",
              });
            } else {
              this.$message({
                message: res.msg,
                type: "warning",
              });
            }
          },
          (res) => { }
        );
      });
    },
    //日程提醒详情
    toCalendarDetails(item, index) {
      this.currentAgenda = item;
      this.newCalendarClick(3);
      this.calendarList.splice(index, 1);
    },
    //日程删除
    delSchedule() {
      delSchedule_axios({
        userid: this.myInfo.id,
        scheduleid: this.currentAgenda.ID,
      })
        .then((res) => {
          if (res.result == 200) {
            for (let i = 0; i < this.scheduleList.length; i++) {
              if (this.scheduleList[i].ID == this.currentAgenda.ID) {
                this.scheduleList.splice(i, 1);
                this.newCalendarShow = false;
                this.editFlag = true; //zk新增，编辑框隐藏之后，编辑按钮可用
                if (this.newCalendarTitle != 4)
                  this.$Message.success("删除成功");
                this.$forceUpdate();
              }
            }
            this.daysAddSchedule();
            this.programmeTimeAddSchedule();
            //改由ws推送
            //this.getSchedule();
          } else {
            this.$Message.warning(res.msg);
          }
        })
        .catch((error) => {
          this.$Message.warning("服务器出错,稍后再试5");
        });
    },
    initToday() {
      this.initData(null);
      this.currentDayInit();
    },
    //日程添加
    newCalendarClick(title) {
      this.newCalendarShow = true;
      this.newCalendarTitle = title;
      if (title == 1) {
        this.$refs.newCalendar.addCalendar();
        this.participant = this.checkPersonArray = []; // 日程提醒人员<==>添加日程提醒组件人员
      } else if (title == 4) {
        // 修改日程
        if (this.editFlag) {
          //zk新增，编辑按钮可用时
          this.$refs.newCalendar.editEvent();
          let listId = null,
            listName = null;
          if (this.currentAgenda.MENBERID.indexOf(",") != -1) {
            listId = this.currentAgenda.MENBERID.split(","); // 人员ID
            listName = this.currentAgenda.NAME.split(","); // 人员NAME
            for (let i = 0; i < listId.length; i++) {
              this.participant.push({
                id: listId[i],
                name: listName[i],
              });
            }
            for (let item of this.participant) {
              // 把已存在的人员添加到，添加人组件数组中，并去除自己
              if (item.id != this.myInfo.id) {
                this.checkPersonArray.push(item);
              }
            }
          } else {
            this.participant.push({
              id: this.currentAgenda.MENBERID,
              name: this.currentAgenda.NAME,
            });
          }
          this.$refs.newCalendar.editEvent2();
          this.editFlag = false; //zk新增,处于编辑状态时，编辑按钮禁用
          if (this.currentAgenda.REPEATPLAN == 6) {
            this.form.schedulerType = this.currentAgenda.SCHEDULERTYPE;
            this.form.repeatRate = this.currentAgenda.REPEATRATE;
            this.form.repeatTimes = this.currentAgenda.REPEATTIMES;
          }
        } else {
          //提醒用户当前已处于编辑状态
          this.$Message.warning("当前已处于编辑状态");
        }
      }
      this.$refs.newCalendar.location();
      this.$forceUpdate();
    },
    scheduleSel(item) {
      this.currentAgenda = item;
      this.newCalendarClick(2);
    },
    //初始化当前时间
    currentDayInit() {
      let currentDate = new Date();
      this.currentDay = currentDate.getDate();
      this.currentYear = currentDate.getFullYear();
      this.currentMonth = currentDate.getMonth() + 1;
      this.currentWeek = currentDate.getDay();
      if (this.currentWeek == 0) {
        this.currentWeek = 7;
      }
      for (let i = 0; i < this.days.length; i++) {
        if (
          new Date(this.days[i].day).toDateString() ===
          currentDate.toDateString()
        ) {
          this.currentDayIndex = i;
          this.daysAddSchedule();
          this.programmeTimeAddSchedule();
        }
      }
    },
    // 初始化日程24小时
    programmeTimeInit() {
      let time = 0;
      for (let i = 0; i < 24; i++) {
        if (i < 10) {
          time = `0${i}:00`;
        } else {
          time = i + ":00";
        }
        this.programmeTimeList.push({ time: time, timeHours: i, schedule: [] });
      }
    },
    // 匹配24小时日程数据
    programmeTimeAddSchedule() {
      for (let i = 0; i < this.programmeTimeList.length; i++) {
        this.programmeTimeList[i].schedule = [];
      }
      for (
        let i = 0;
        i < this.days[this.currentDayIndex].schedule.length;
        i++
      ) {
        for (let j = 0; j < this.programmeTimeList.length; j++) {
          if (
            new Date(
              this.days[this.currentDayIndex].schedule[i].STARTTIME
            ).getHours() == this.programmeTimeList[j].timeHours
          ) {
            this.programmeTimeList[j].schedule.push(
              this.days[this.currentDayIndex].schedule[i]
            );
          }
        }
      }
    },
    //匹配每天日程
    daysAddSchedule() {
      for (let i = 0; i < this.days.length; i++) {
        this.days[i].schedule = [];
      }
      for (let i = 0; i < this.scheduleList.length; i++) {
        for (let j = 0; j < this.days.length; j++) {
          if (
            new Date(this.scheduleList[i].STARTTIME).toDateString() ===
            new Date(this.days[j].day).toDateString()
          ) {
            this.days[j].schedule.push(this.scheduleList[i]);
          }
        }
      }
    },
    showContacts(a, b) {
      this.modalTitle = 5;
      this.modalFirst = true;
    },

    getSchedule(init) {
      //获取日程
      getSchedule_axios({ userid: this.myInfo.id })
        .then((res) => {
          if (res.result == 200) {
            this.scheduleList = res.data;
            // console.log('获取日程',res.data)
            this.scheduleList.sort(function (a, b) {
              return b["STARTTIME"] < a["STARTTIME"] ? 1 : -1;
            });
            // 新增过滤时间
            this.newScheduleList = this.scheduleList.filter(
              (item) =>
                item.STARTTIME &&
                item.STARTTIME.substring(0, 10) == this.lastClickTime
            ); //zk修改，添加完日程之后，显示上一次点击的日期的日程

            this.daysAddSchedule();
            this.programmeTimeAddSchedule();
            if (init) {
              this.currentDayInit();
            }
            // 根据结束时间过滤掉失效的日程
            let scheduleTimeARR = this.scheduleList.filter(
              (item) =>
                this.$newDateGetTime(item.ENDTIME) > this.$newDateGetTime() ||
                item.REPEATPLAN != 0
            );
            // 根据开始时间小于当前时间并且没设置循环提醒
            scheduleTimeARR = scheduleTimeARR.filter(
              (item) =>
                !(
                  this.$newDateGetTime(item.STARTTIME) <
                  this.$newDateGetTime() && item.REPEATPLAN == 0
                )
            );
            // 初始化清除所有日程定时器
            if (this.scheduleARR.length > 0) {
              this.scheduleARR.map((item) => {
                clearInterval(item);
              });
            }
            // 循环开启定时器
            if (scheduleTimeARR.length > 0) {
              /**
               * 提醒时间  0:无  1:开始   2:5分钟前  3:15分钟前 4:30分钟前 5:1个小时前 6:2个小时前 7:1天前 8:2天前 9:一周前
               * 提醒频率  0:无  1:每天   2:每周     3:每两周   4:每月     5:每年
               * ISALLDAY 是否全天
               * REPEATPLAN 重复时间(每天，每周，每月，每年)
               * REMINDTIME 提醒时间（5分钟前提醒，15分钟前提醒）
               * STARTTIME 开始时间
               * ENDTIME 结束时间
               * ENDREMINDTIME 结束提醒时间
               * ID 日程id
               * THEME 提醒内容
               */
              let _this = this;
              let remindTimeBefore = function (time, startTime) {
                // 提醒时间
                let timeNum = 0;
                switch (parseInt(time)) {
                  case 0:
                    timeNum = 0;
                    break;
                  case 1:
                    timeNum = 0;
                    break;
                  case 2:
                    timeNum = 5 * 60;
                    break;
                  case 3:
                    timeNum = 15 * 60;
                    break;
                  case 4:
                    timeNum = 30 * 60;
                    break;
                  case 5:
                    timeNum = 1 * 60 * 60;
                    break;
                  case 6:
                    timeNum = 2 * 60 * 60;
                    break;
                  case 7:
                    timeNum = 1 * 24 * 60 * 60;
                    break;
                  case 8:
                    timeNum = 2 * 24 * 60 * 60;
                    break;
                  case 9:
                    timeNum = 7 * 24 * 60 * 60;
                    break;
                }
                return _this.$newDateGetTime(startTime) - timeNum;
              };
              let taktTime = function (time) {
                // 提醒频率
                let timeNum = null;
                let month = new Date(
                  new Date().getFullYear(),
                  new Date().getMonth() + 1,
                  0
                ).getDate();
                let years =
                  (new Date().getFullYear() % 400 == 0 ||
                    new Date().getFullYear() % 100 != 0) &&
                  new Date().getFullYear() % 4 == 0;
                switch (parseInt(time)) {
                  case 1:
                    timeNum = 1 * 24 * 60 * 60;
                    break;
                  case 2:
                    timeNum = 7 * 24 * 60 * 60;
                    break;
                  case 3:
                    timeNum = 14 * 24 * 60 * 60;
                    break;
                  case 4:
                    timeNum = month * 24 * 60 * 60;
                  case 5:
                    timeNum = (years ? 366 : 365) * 24 * 60 * 60;
                }
                return timeNum;
              };
              // 提醒时间对象定时器
              for (let i in scheduleTimeARR) {
                // console.log('提醒时间对象定时器',scheduleTimeARR[i])
                let repeatPlan = parseInt(scheduleTimeARR[i].REPEATPLAN); // 循环提醒
                let scheduleUUID = this.scheduleStr + i; // 定时器名称
                //不存在自定义日程提醒
                if (repeatPlan != 6) {
                  let timeing = remindTimeBefore(
                    scheduleTimeARR[i].REMINDTIME,
                    scheduleTimeARR[i].STARTTIME
                  ); // 第一次提醒的时间
                  const time1 = timeing;
                  console.log("第一次提醒时间", time1);
                  if (this.$newDateGetTime() - timeing >= 0) {
                    // 第一次提醒时间已失效
                    let num = parseInt(
                      (this.$newDateGetTime() - timeing) / taktTime(repeatPlan)
                    ); // 超过间隔时间次数
                    timeing += (num + 1) * taktTime(repeatPlan);
                    console.log("第一次提醒时间已失效", timeing);
                  }
                  this.scheduleARR.push(
                    (scheduleUUID = setInterval(() => {
                      // console.log(this.$newDateGetTime(),'<=当前时间，下一次提醒时间=>', timeing)
                      if (this.$newDateGetTime() == timeing) {
                        // 新增添加右下角标提醒
                        // 参数(id,type,value,headUrl,sendName,headType)
                        this.messageTips(
                          "schedule",
                          "",
                          scheduleTimeARR[i].THEME,
                          "",
                          "日程提醒",
                          "7"
                        );
                        this.calendarList.push(scheduleTimeARR[i]); // 日程提醒列表
                        this.getSchedule("init"); // 重置下一次提醒时间
                      }
                    }, 1000))
                  );
                } else {
                  //自定义日程提醒
                  let d4 = 1000000;
                  switch (scheduleTimeARR[i].SCHEDULERTYPE) {
                    case "6": //每周几提醒
                      d4 = this.getWeekinterval(
                        scheduleTimeARR[i].REPEATRATE,
                        scheduleTimeARR[i].STARTTIME
                      );
                      if (d4 < 0) {
                        d4 = this.getWeekinterval(
                          parseInt(scheduleTimeARR[i].REPEATRATE) + 7,
                          scheduleTimeARR[i].STARTTIME
                        );
                      }
                      break;
                    case "5": //每月几号提醒
                      d4 = this.getMonthinterval(
                        scheduleTimeARR[i].REPEATRATE,
                        scheduleTimeARR[i].STARTTIME,
                        1
                      );
                      if (d4 < 0) {
                        d4 = this.getMonthinterval(
                          scheduleTimeARR[i].REPEATRATE,
                          scheduleTimeARR[i].STARTTIME,
                          2
                        );
                      }
                      break;
                    case "7": //每年几号提醒
                      d4 = this.getYearinterval(
                        scheduleTimeARR[i].REPEATRATE,
                        scheduleTimeARR[i].STARTTIME,
                        1
                      );
                      if (d4 < 0) {
                        d4 = this.getYearinterval(
                          scheduleTimeARR[i].REPEATRATE,
                          scheduleTimeARR[i].STARTTIME,
                          2
                        );
                      }
                      break;
                  }
                  console.log(isNaN(d4), "提醒时间间隔", d4);
                  if (d4 > 86400000 || isNaN(d4)) {
                    //间隔时间超过1天
                    this.scheduleARR.push(
                      (scheduleUUID = setTimeout(() => {
                        // 新增添加右下角标提醒
                        // 参数(id,type,value,headUrl,sendName,headType)
                        this.getSchedule("init"); // 1天后再获取提醒时间
                      }, 86400000))
                    );
                  } else {
                    this.scheduleARR.push(
                      (scheduleUUID = setTimeout(() => {
                        // 新增添加右下角标提醒
                        // 参数(id,type,value,headUrl,sendName,headType)
                        this.messageTips(
                          "schedule",
                          "",
                          scheduleTimeARR[i].THEME,
                          "",
                          "日程提醒",
                          "7"
                        );
                        this.calendarList.push(scheduleTimeARR[i]); // 日程提醒列表
                        console.log("重置下一次提醒时间", d4);
                        this.getSchedule("init"); // 重置下一次提醒时间
                      }, d4))
                    );
                  }
                }
              }
            }
          } else {
            this.$Message.warning(res.msg);
          }
        })
        .catch((error) => {
          this.$Message.warning("服务器出错,稍后再试6");
        });
    },
    //获取周间隔
    getWeekinterval(i, e) {
      const d1 = this.$utilJs.getThisWeek(i).dateFormat("yyyy-MM-dd");
      const d2 = this.$date(e, "hh:mm");
      const d3 = d1 + " " + d2;
      console.log("获取周间隔", d3);
      return new Date(d3).getTime() - new Date().getTime();
    },
    //月间隔
    getMonthinterval(i, e, type) {
      const d1 = new Date().dateFormat("yyyy-MM-");
      const d2 = this.$date(e, "hh:mm");
      const d3 = d1 + i + " " + d2;
      if (type == 1) {
        //当前月
        console.log("获取月间隔", d3);
        return new Date(d3).getTime() - new Date().getTime();
      }
      const d4 = this.$utilJs.getNextMonth(d1 + i);
      const d5 = d4 + " " + d2;
      console.log("获取月间隔", d5);
      return new Date(d5).getTime() - new Date().getTime();
    },
    //年间隔
    getYearinterval(i, e, type) {
      // if(i.length>5){
      //   i = i.slice(-5)
      // }
      const d1 = new Date().dateFormat("yyyy");
      const d2 = this.$date(e, "hh:mm");
      const d3 = d1 + "-" + i + " " + d2;
      if (type == 1) {
        //今年
        console.log("获取年间隔", d3);
        return new Date(d3).getTime() - new Date().getTime();
      }
      const d4 = parseInt(d1) + 1;
      const d5 = d4 + "-" + i + " " + d2;
      console.log("获取年间隔", d5);
      return new Date(d5).getTime() - new Date().getTime();
    },
    //日程提交
    submit(obj) {
      addSchedule(obj)
        .then((res) => {
          if (res.result == 200) {
            if (this.newCalendarTitle == 4) this.delSchedule(); // 先调用删除接口
            this.newCalendarShow = false; //zk注释，新建完成之后隐藏日程配置框
            this.editFlag = true; //zk新增，编辑框隐藏之后，编辑按钮可用
            this.isDisabled = false; //日期组件禁用
            this.participant = []; //清空提醒人列表
            this.resetModalFirst();
            this.$refs.newCalendar.scheduleAugumentsInit(); //清空日程配置框中的内容
            this.$Message.success(res.msg);
            //改由ws推送
            //this.getSchedule(); //重新请求日程
          } else {
            this.$Message.warning(res.msg);
          }
        })
        .catch((error) => {
          this.$Message.warning("服务器出错,稍后再试7");
        });
    },

    daysClick(days, index) {
      this.currentDayIndex = index;
      this.programmeTimeAddSchedule();
      this.currentDay = days.day.getDate();
      this.currentYear = days.day.getFullYear();
      this.currentMonth = days.day.getMonth() + 1;
      this.currentWeek = days.day.getDay();
      // 新增日程过滤
      let year = days.day.getFullYear();
      let month =
        days.day.getMonth() + 1 >= 10
          ? days.day.getMonth() + 1
          : "0" + (days.day.getMonth() + 1);
      let day =
        days.day.getDate() >= 10
          ? days.day.getDate()
          : "0" + days.day.getDate();
      let time = year + "-" + month + "-" + day;
      this.lastClickTime = time; //zk新增，点击之后更新lastClickTime
      this.newScheduleList = this.scheduleList.filter(
        (item) => item.STARTTIME && item.STARTTIME.substring(0, 10) == time
      );
    },
    initData(cur) {
      var leftcount = 0; //存放剩余数量
      var date;
      if (cur) {
        date = new Date(cur);
      } else {
        var now = new Date();
        var d = new Date(
          this.$utilJs.formatDate(now.getFullYear(), now.getMonth(), 1)
        );
        d.setDate(35);
        date = new Date(
          this.$utilJs.formatDate(
            d.getFullYear() ? d.getFullYear() : new Date().getFullYear(),
            d.getMonth() ? d.getMonth() + 1 : new Date().getMonth() + 1,
            1
          )
        );
      }
      // this.currentDay = date.getDate();
      this.currentDay = date.getDate();
      this.currentYear = date.getFullYear();
      this.currentMonth = date.getMonth() + 1;
      this.currentWeek = date.getDay(); // 1...6,0
      if (this.currentWeek == 0) {
        this.currentWeek = 7;
      }
      var str = this.$utilJs.formatDate(
        this.currentYear,
        this.currentMonth,
        this.currentDay
      );
      this.days.length = 0;
      // 今天是周日，放在第一行第7个位置，前面6个
      //初始化本周
      for (var i = this.currentWeek - 1; i >= 0; i--) {
        var d = new Date(str);
        d.setDate(d.getDate() - i);
        var dayobject = {}; //用一个对象包装Date对象  以便为以后预定功能添加属性
        dayobject.day = d;
        dayobject.schedule = [];
        this.days.push(dayobject); //将日期放入data 中的days数组 供页面渲染使用
      }
      //其他周
      for (var i = 1; i <= 35 - this.currentWeek; i++) {
        var d = new Date(str);
        d.setDate(d.getDate() + i);
        var dayobject = {};
        dayobject.day = d;
        dayobject.schedule = [];
        this.days.push(dayobject);
      }
      if (cur) {
        this.currentWeek = this.days[this.currentDayIndex].day.getDay();
        this.currentDay = this.days[this.currentDayIndex].day.getDate();
        this.daysAddSchedule();
        this.programmeTimeAddSchedule();
      }
    },
    pickPre(year, month) {
      // setDate(0); 上月最后一天
      // setDate(-1); 上月倒数第二天
      // setDate(dx) 参数dx为 上月最后一天的前后dx天
      var d = new Date(this.$utilJs.formatDate(year, month, 1));
      d.setDate(0);
      this.initData(
        this.$utilJs.formatDate(d.getFullYear(), d.getMonth() + 1, 1)
      );
    },
    pickNext(year, month) {
      var d = new Date(this.$utilJs.formatDate(year, month, 1));
      d.setDate(35);
      this.initData(
        this.$utilJs.formatDate(d.getFullYear(), d.getMonth() + 1, 1)
      );
    },

    // 获取各个分组下的成员
    getUserCategoryMembers() {
      this.flagHeadType = 2;
      console.log("this.friendsGrou.length", this.friendsGroup.length);
      for (let i = 0; i < this.friendsGroup.length; i++) {
        getUserCategoryMembers_axios({
          userid: this.myInfo.id,
          categoryid: this.friendsGroup[i].ID,
        })
          .then((res) => {
            if (res.result == 200) {
              let arr = (res.data || []).sort(this.$personStatusSort("status"));
              this.friendsGroup[i].USER = arr;
              console.log(
                "this.friendsGroup[i].USER.length",
                this.friendsGroup[i].USER.length
              );
              for (let j = 0; j < this.friendsGroup[i].USER.length; j++) {
                this.$set(
                  this.friendsGroup[i].USER[j],
                  "GROUPID",
                  this.friendsGroup[i].ID
                );
              }
              this.isLinkman();
              // 新增下载头像
              this.friendsGroup[i].USER.map((item) => {
                this.downLoadHeadPath(item);
              });
            } else {
              this.$Message.warning(res.msg);
            }
          })
          .catch((error) => {
            // console.log("服务器出错,稍后再试10",error);
            // this.$Message.warning("服务器出错,稍后再试10");
          });
      }
    },
    friendItemClick(index) {
      this.curfriendGrouping = this.friendsGroup[index];
      console.log(index, this.curfriendGrouping, this.friendsGroup, 6231);
    },
    //删除分组
    delUserCategory() {
      delUserCategory_axios({
        userid: this.myInfo.id,
        categoryid: this.curfriendGrouping.ID,
      })
        .then((res) => {
          if (res.result == 200) {
            this.$Message.success("删除分组成功");
            this.getUserCategoryNames();
          } else {
            this.$Message.warning(res.msg);
          }
        })
        .catch((error) => {
          this.$Message.warning("服务器出错,稍后再试11");
        });
    },
    //添加常用联系人分组
    addUserCategory() {
      if (this.userCategory.trim() == "") {
        this.$Message.warning("请输入正确名称");
        return;
      }
      if (this.curfriendGrouping.index == 0) {
        addUserCategory_axios({
          userId: this.myInfo.id,
          name: this.userCategory,
        })
          .then((res) => {
            if (res.result == 200) {
              this.$Message.success("添加分组成功");
            } else {
              this.$Message.warning(res.msg);
            }
            this.getUserCategoryNames();
          })
          .catch((error) => {
            this.$Message.warning("服务器出错,稍后再试12");
          });
      } else if (this.curfriendGrouping.index == 1) {
        this.renameUserCategory();
      }
    },
    //查询好友分组
    getUserCategoryNames() {
      this.flagHeadType = 2;
      let defaultValue = [
        {
          ID: "1",
          NAME: "常用联系人",
          USERID: "",
          RANK: 0,
          SORT: 1,
          USER: [],
        },
      ];
      getUserCategoryNames_axios({
        userid: this.myInfo.id,
      }).then((res) => {
        if (res.result == 200) {
          this.friendsGroup = [...defaultValue, ...(res.data || [])];
        } else {
          this.friendsGroup = defaultValue;
        }
        this.getUserCategoryMembers();
      });
    },
    friendsEdit(index) {
      console.log(index, this.curfriendGrouping, 6301);
      this.curfriendGrouping.index = index;
      this.friendsEditShow = false;
      if (index == 0) {
        this.userCategory = "";
        this.userCategoryShow = !this.userCategoryShow;
      } else if (index == 1) {
        this.userCategory = this.curfriendGrouping.NAME;
        this.userCategoryShow = !this.userCategoryShow;
      } else if (index == 2) {
        this.delUserCategory();
      } else if (index == 3) {
        this.managementShow = true;
      }
    },
    //重命名分组
    renameUserCategory() {
      for (let i = 0; i < this.friendsGroup.length; i++) {
        if (this.friendsGroup[i].NAME == this.userCategory.trim()) {
          this.$Message.warning("分组名已存在");
          return;
        }
      }
      renameUserCategory_axios({
        userid: this.myInfo.id,
        categoryid: this.curfriendGrouping.ID,
        categoryname: this.userCategory.trim(),
      })
        .then((res) => {
          if (res.result == 200) {
            this.curfriendGrouping.NAME = this.userCategory;
            this.$forceUpdate();
          } else {
            this.$Message.warning(res.msg);
          }
        })
        .catch((error) => {
          this.$Message.warning("服务器出错,稍后再试13");
        });
    },
    friendEditPosition(e, item) {
      console.log(e, item, 6339);
      this.friendsEditShow = true;
      this.getCoordinate(e);
      this.curfriendGrouping = item;
    },
    //获取坐标
    getCoordinate(e) {
      let rect = e.target.getBoundingClientRect();
      let maxTop = document.body.clientHeight;
      this.menuTop = maxTop - rect.top - 180 > 0 ? rect.top + 10 : maxTop - 180;
      this.menuLeft = rect.left + 160 || 0;
    },
    testbtnn(a) { },

    addNoticeClick() {
      console.log(654321,'哈哈哈哈')
      this.addNoticeShow = true;
      //this.groupNoticeShow = false;
    },
    groupNoticeClick() {
      this.groupNoticeShow = !this.groupNoticeShow;
      if (this.groupNoticeShow) {
        this.getGroupPublicNotices(); // 获取群公告
        // this.getGroupPosition();// 获取群公告权限
      }
    },
    getGroupPublicNotices() {
      getGroupPublicNotices_axios({ groupid: this.toInfo.id })
        .then((res) => {
          if (res.result == 200) {
            console.log(res.data, 6059);
            this.groupNoticeList = res.data || [];
            for (let i = 0, len = this.groupNoticeList.length; i < len; i++) {
              this.groupNoticeList[i].VALUE = this.groupNoticeList[
                i
              ].VALUE.replace(/(\r\n|\n|\r)/gm, "<br>");
            }
          } else {
            this.$Message.warning(res.msg);
          }
        })
        .catch((error) => {
          this.$Message.warning("服务器出错,稍后再试14");
        });
      console.log("拿到的群公告", this.groupNoticeList);
    },

    toNoticeDetails(item, index) {
      // for (let i = 0; i < this.remindList.length; i++) {
      //   if ((item.id || item.ID) == this.remindList[i].ID) {
      //     this.remindStatus = 2;
      //     this.processedTime = this.remindList[i].REMIND_TIME;
      //     this.processedItem = this.remindList[i];
      //     this.addProcessedShow = true;
      //     this.setSider(2);
      //     this.workListShow(5);
      //   }
      // }
      this.setSider(2);
      this.workListShow(5);
      this.openOfficialBox(item, 2);
      this.noticeList.splice(index, 1);
    },
    //删除待办
    delRemind(item, index) {
      delRemind_axios({
        userid: this.myInfo.id,
        messageid: item.MESSAGE_ID,
        remindid: item.ID,
      })
        .then((res) => {
          if (res.result == 200) {
            this.remindList.splice(index, 1);
            this.$Message.success("删除待办成功");
            this.remindListSortList(this.remindList); // 我的待办进行排序
          } else {
            this.$Message.warning(res.msg);
          }
        })
        .catch((error) => {
          this.$Message.warning("服务器出错,稍后再试18");
        });
    },
    // //查看待办详情
    // examineRemindInfo(item) {
    //   this.remindStatus = 2;
    //   this.processedTime = item.REMIND_TIME;
    //   this.processedItem = item;
    //   this.addProcessedShow = true;
    // },
    // //更新待办时间
    // updateRemindTime(item) {
    //   this.remindStatus = 1;
    //   this.processedTime = item.REMIND_TIME;
    //   this.processedItem = item;
    //   this.addProcessedShow = true;
    // },
    //更新待办完成状态
    updateIsDone(item) {
      let option = 0;
      if (item.ISDONE == 0) {
        option = 1;
      } else {
        option = 0;
      }
      updateIsDone_axios({
        userid: this.myInfo.id,
        option: option,
        id: item.ID,
      })
        .then((res) => {
          if (res.result == 200) {
            this.$set(item, "ISDONE", option);
            // this.getRemind();
            this.$Message.success("更新状态成功");
            this.remindListSortList(this.remindList); // 排序
          } else {
            this.$Message.warning("更新状态失败,请稍后再试");
          }
        })
        .catch((error) => {
          this.$Message.warning("服务器出错,稍后再试19");
        });
    },
    // //反馈提交后关闭init待办页面
    // closeRemindView() {
    //   this.isOpenOfficial = false;
    //   this.getRemind();
    // },
    // isUpdateRemindList() {
    //   this.getRemind();
    // },
    remindListSortList(arr) {
      arr.sort(function (a, b) {
        let x = parseInt(a.ISDONE);
        let y = parseInt(b.ISDONE);
        return x - y;
      });
    },
    remindOfficialListSortList(arr) {
      arr.sort(function (a, b) {
        let x = new Date(a.CREATEDATE).getTime();
        let y = new Date(b.CREATEDATE).getTime();
        return y - x;
      });
    },

    //新增UI添加待办
    addRemind(info) {
      this.remindStatus = info.state;
      this.processedItem = info.item;
      this.$refs.myAddProcessing.processedTime = info.item.REMIND_TIME;
      // this.processedTime = info.item.REMIND_TIME;
      this.$refs.myAddProcessing.addBacklog();
      // this.addBacklog();
      // 更新状态
      info.item.ISDONE = 0;
      //this.updateIsDone(info.item);
    },

    addBacklogShow(item) {
      this.remindStatus = 0;
      this.addProcessedShow = true;
      this.processedItem = item;
      this.$refs.myAddProcessing.processedTime = "";
      // this.processedTime = "";
    },
    //系统消息个人信息显示
    newsInfo(item) {
      console.log("系统消息个人信息显示", item);
      this.newsMemberInfo = item;
      this.newsMemberInfoShow = !this.newsMemberInfoShow;
    },
    //群二维码显示
    qrcodeShow(code) {
      this.groupCodeShow = true;
      this.groupCode = this.$utilJs.utf16to8(code);
    },
    //添加群成员，zk1215标识
    addMemberOption(option, item) {
      let initid = this.$func.uuid();
      // this.$set(item, "agreest", option);
      // tools.operationalDatabase(
      //   `UPDATE ${this.sqlTable.group_message} SET agreest='${option}' WHERE messageId='${item.messageId}';`
      // );
      let member = [{ type: 0, name: item.userName, value: item.applyid }];
      this.ws.send(
        this.$publicSend(initid, "1.201", "1.1.0018", {
          option: option,
          userId: this.myInfo.id,
          groupid: item.groupid,
          members: JSON.stringify(member),
          userName: this.myInfo.name,
          groupName: item.groupName,
          messageId: item.messageId,
        })
      );
    },
    getSystemNoRead() {
      //获取未读系统消息数
      return tools.operationalDatabase(
        `SELECT count(isRead) AS num FROM ${this.sqlTable.group_message} WHERE isRead='0';`,
        1
      );
    },
    getSystemList() {
      let res = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.group_message} ORDER BY time DESC limit 1;`,
        1
      );
      let noRead = this.getSystemNoRead().list[0]
        ? this.getSystemNoRead().list[0].num
        : 0;
      let list = res.list;
      if (list[0]) {
        list[0].noRead = noRead;
        list[0].systemId = "3494fbfb-98eb-4d31-8553-248e1a8b428a";
      }
      return list;
    },
    //收到通知消息插入表格
    insertNoticeData(body) {
      let initid = this.$func.uuid();
      var ab = tools.operationalDatabase(
        `INSERT INTO ${this.sqlTable.audit_notice
        }(groupName,time,type,opinion,messageId,sendName,isRead) VALUES ('${body.groupName
        }','${new Date().getTime()}','1','${body.msg}','${initid}','${body.userName
        }','0')`
      );
      for (let i = 0, len = this.sessionList.length; i < len; i++) {
        if (this.sessionList[i].systemId) {
          this.$set(this.sessionList[i], "time", new Date().getTime());
          this.$set(
            this.sessionList[i],
            "noRead",
            parseInt(this.sessionList[i].noRead) || 0
          ) + 1;
          this.$set(this.sessionList[i], "isRead", 0);
          if (this.toInfo.systemId) {
            let res = tools.operationalDatabase(
              `SELECT * FROM ${this.sqlTable.group_message} ORDER BY time DESC;`,
              1
            );
            let notice = tools.operationalDatabase(
              `SELECT * FROM ${this.sqlTable.audit_notice} ORDER BY time DESC;`,
              1
            );
            this.auditNotice = notice.list || [];
            this.groupNews = res.list || [];
          }
          this.sortSessionList();
          return;
        }
      }

      this.sessionList.unshift({
        systemId: "3494fbfb-98eb-4d31-8553-248e1a8b428a",
        time: new Date().getTime(),
        noRead: 1,
        isRead: 0,
        value: `${body.groupName} ${body.msg == "0" ? "已同意" : "谢绝了"
          }加群请求`,
      });
      this.sortSessionList();
    },
    //收到系统消息插入表格
    insertSystemData(body, h) {
      var ab = tools.operationalDatabase(
        `INSERT INTO ${this.sqlTable.group_message
        }(applyid,groupid,shareid,userName,groupName,head,department,time,type,isRead,messageId,sendName,jobTitle,gender) VALUES ('${body.applyid
        }','${body.groupid}','${body.shareid}','${body.userName}','${body.groupName
        }','${body.head}','${body.department
        }','${new Date().getTime()}','1',0,'${h.key}','${body.shareName}','${body.applyJobTitle
        }','${body.applyGender}')`
      );
      for (let i = 0, len = this.sessionList.length; i < len; i++) {
        if (this.sessionList[i].systemId) {
          this.$set(this.sessionList[i], "time", new Date().getTime());
          this.$set(
            this.sessionList[i],
            "noRead",
            (parseInt(this.sessionList[i].noRead) || 0) + 1
          );
          this.$set(this.sessionList[i], "isRead", 0);
          this.$set(
            this.sessionList[i],
            "value",
            `${body.userName} 申请加入 ${body.groupName}`
          );
          if (this.toInfo.systemId) {
            let res = tools.operationalDatabase(
              `SELECT * FROM ${this.sqlTable.group_message} ORDER BY time DESC;`,
              1
            );
            let notice = tools.operationalDatabase(
              `SELECT * FROM ${this.sqlTable.audit_notice} ORDER BY time DESC;`,
              1
            );
            this.auditNotice = notice.list || [];
            this.groupNews = res.list || [];
          }
          this.sortSessionList();
          return;
        }
      }
      this.sessionList.unshift({
        systemId: "3494fbfb-98eb-4d31-8553-248e1a8b428a",
        time: new Date().getTime(),
        noRead: 1,
        isRead: 0,
        value: `${body.userName} 申请加入 ${body.groupName}`,
      });
      this.sortSessionList();
    },
    //更新系统消息状态(同意与否)
    updateSystemData(b, h) {
      console.log(
        "更新系统消息状态",
        `UPDATE ${this.sqlTable.group_message} SET agreest='${b.option}' WHERE messageId='${h.key}';`
      );
      tools.operationalDatabase(
        `UPDATE ${this.sqlTable.group_message} SET agreest='${b.option}' WHERE messageId='${h.key}';`
      );
      let res = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.group_message} ORDER BY time DESC;`,
        1
      );
      this.groupNews = res.list || [];
      this.$forceUpdate();
    },
    testjoinGroup() {
      let initid = this.$func.uuid();
      this.ws.send(
        this.$publicSend(initid, "1.201", "1.1.0017", {
          userId: this.myInfo.id,
          groupid: "6b5bc238-e5cf-4d0a-b001-f04b3fde0e7f",
          members: "TW18",
          userName: this.myInfo.name,
          groupName: "测试测试",
          head: this.myInfo.head,
          department: "天物",
          shareName: "吕启凡",
          applyJobTitle: this.myInfo.jobtitle,
          applyGender: this.myInfo.gender,
          introduce: "",
        })
      );
    },
    filesref() {
      if (this.tabList.length <= 0) {
        this.getFileCatalog();
      } else {
        this.getFileCatalog(this.tabList[this.curren_tab].ID);
      }
    },
    setRemoteType(type) {
      this.remoteType = type;
    },
    setControlType(type) {
      this.control_type = type;
      this.remoteState = type;
      this.$forceUpdate();
    },
    controlClose() {
      this.controlViwe_show = false;
    },
    controlFn(type, user = null) {
      //zk128标识，远程控制相关,zk0303新增参数id，用于直接远程
      if (this.control_type == 6 || this.control_type == 0) {
        this.control_type = type;
        this.remoteType = type;
        this.remoteState = type;
        for (let k in this.toInfo) {
          this.requestUser[k] = this.toInfo[k];
        }
        let initid = this.$func.uuid();
        let identification = this.$shell("GetClientIdentification", []);
        this.ws.send(
          this.$publicSend(initid, "1.500", "1.1.1016", {
            label: 2,
            requestId: this.myInfo.id,
            receptionId: user ? user.LoginID : this.toInfo.id, //zk0303修改
            type: this.control_type,
            registerid: this.$store.state.myRegisterid,
            password: this.$store.state.myControlPassword,
            identification: JSON.parse(identification).return_msg,
          })
        );
        this.control_show = false;
        user
          ? (this.toControlName = user.Name)
          : (this.toControlName = this.toInfo.name);
        // this.controlViwe_show = true;//zk14修改，触发函数时不打开弹框，只有请求成功才弹出来
      } else {
        this.$Message.warning({
          content: "正在进行远程服务,稍后再试",
          duration: 0.8,
        });
      }
    },
    // 同屏
    screenFn(type) {
      if (type == 0) {
        // 未设置同屏
        this.setSider(3);
        this.isAutoOpenScreen = true;
      } else {
        // 已设置同屏
        if (this.$store.state.screenObj) {
          this.$wsSendMsg(
            this.toInfo,
            this.$func.uuid(),
            "screen",
            {
              text: this.$store.state.screenObj
                ? JSON.stringify(this.$store.state.screenObj)
                : "",
              gender: this.myInfo.gender || "1",
              head: this.myInfo.headImage || "",
            },
            this.ws
          );
        } else {
          this.$message({
            message: "未设置同屏",
            type: "warning",
          });
          this.setSider(3);
          this.isAutoOpenScreen = true;
        }
      }
      this.control_show = false;
      console.log(this.$store.state.screenObj, "同屏参数");
      // 以下暂废弃 ==>
      // if (type == 9) this.isInviter = true;
      // this.isReceiveShow = false;
      // this.isConsentShow = false;
      // this.screenViwe_show = true;
    },
    // 同屏取消
    screenClose() {
      this.screenViwe_show = false;
    },
    // 同屏 邀请人
    isReceiveShowFn(bol) {
      this.isReceiveShow = bol;
    },
    // 同屏 被邀请人
    isConsentShowFn(bol) {
      this.isConsentShow = bol;
    },
    // 同屏 退出登录 断开中转服务器 结束同屏
    overScreenFn() {
      console.log("准备断开同屏中转服务器");
      let value = this.$ShareScreenAssistance("DisconnectShareScreenServer", [
        this.$store.state.screenRoomNo,
      ]);
      console.log(value, "断开同屏中转服务器");
    },
    controlActive() {
      this.control_show = true;
      this.quickShow = false;
      this.group_info_show = false;
      this.files_show = false;
    },
    sendCancel() {
      this.broadSendList = [];
    },
    modalFirstCancel() {
      this.modalFirst = false;
      this.resetModalFirst();
    },

    checkPersonArrayPush(e, type) {
      if (type == 1) {
        this.checkPersonArray.push(e);
      }
      if (type == 2) {
        this.checkPersonArray = e;
      }
      if (type == 3) {
        this.checkPersonArray.splice(e, 1);
      }
    },

    setMyposition(val) {
      this.my_position = val;
    },
    editMenuShow(args) {
      args[0].preventDefault();
      if (args[1]) {
        this.editPositionShow = true;
        return;
      }
      this.editPositionShow = !this.editPositionShow;
    },
    broadClose() {
      this.broad_show_item = null;
    },
    forwardingSet(files) {
      this.forwardingList = files;
      this.isResetFiles = false;
      this.setModalFirst(3);
    },
    filesViewClose() {
      this.files_show = false;
    },
    filesActive() {
      this.files_show = !this.files_show;
      this.group_info_show = false;
    },
    searchFocus() {
      this.searchResultShow = true;
    },
    cropper_hide() {
      this.cropper_show = false;
    },
    updateInfo() {
      console.log("个人信息修改");
      this.getAndSaveUserInfo();
    },
    closeEdit() {
      this.myMobile = "";
      this.myEmail = "";
      this.myTelephone = "";
      this.edit_section_show = false;
    },
    closeMap() {
      this.show_map = false;
    },
    closeHistorical() {
      this.personal_chat_list = false;
      this.activeRecords = false;
    },
    toGroupFn(args) {
      this.toGroupFunction(args[0], args[1]);
    },
    viewTargetHide() {
      this.viewTargetShow = false;
    },
    messageScrollChange() {
      // currentTempChat
      //新增消息列表分页 上滑
      // 2022/7/13 修改 此前当聊天内容为21条时，不去拉取第21条记录
      console.log(this.chatList, this.chatMsgTotal, 7101);
      if (this.chatList[1].length < this.chatMsgTotal) {
        this.chatMsgPage++;
        let page = this.chatMsgPage * this.chatMsgPageSize; //zk修改，去掉+1
        // if(page > this.chatMsgTotal) {
        // 	this.chatMsgPage = this.chatMsgPage - 1;
        // 	return;
        // }
        let id = this.toInfo.id;
        let isTrue = this.toInfo.isGroup == "1";
        let str = `${isTrue ? this.sqlTable.messageList : this.sqlTable.privateList
          } a left join ${this.sqlTable.userInformation
          } b on a.sendId=b.id WHERE ${isTrue
            ? `a.receiveId='${id}'`
            : `a.sendId='${id}' OR a.receiveId='${id}'`
          }`;

        console.log(page, 7118);
        let res = tools.operationalDatabase(
          `SELECT a.*,b.head,b.gender FROM ${str} ORDER BY time DESC LIMIT '${page}', '${this.chatMsgPageSize}';`,
          1
        );
        console.log(res, 7120);
        //新增下载头像
        if (res.list.length > 0)
          res.list.map((item) => this.downLoadHeadPath(item));
        //zk1230新增，查询到的结果剔除掉已在chatlist0中的消息
        let idxArr = [];
        this.chatList[0].forEach((item) => {
          idxArr.push(item.messageId);
        });
        //  console.log(idxArr,"chatlist0")
        let idxArr1 = [];
        this.firstFrame.forEach((item) => {
          //zk14新增，针对不超过20条的去重
          idxArr1.push(item.messageId);
        });
        //  console.log(idxArr1,"chatlist1")
        let idxs = idxArr.concat(idxArr1);
        let tempArr = res.list.filter((item) => {
          return idxs.indexOf(item.messageId) == -1;
        });

        this.chatList[1] = this.chatList[1].concat(tempArr);

        //  this.chatList[1] = this.chatList[1].concat(res.list);
        this.$forceUpdate();
        // }
        // if (this.show_index < this.chatList[1].length&&!this.isMultiSelect){
        // 	this.show_index += 5;
        // 	this.$forceUpdate();
      }
    },
    messageScrollChangeBottom() {
      // loading......
    },
    getMemberInfoFn(args) {
      this.getMemberInfo(args[0], args[1], args[2]);
    },
    // 获取收藏列表
    getCollect() {
      getCollect_axios({
        userid: this.myInfo.id,
      }).then((res) => {
        if (res.result == 200) {
          let value = res.data || [];
          for (let i = 0; i < value.length; i++) {
            if (value[i].FILE_TYPE == "video") {
              //zk0204标注，获取收藏列表
              let videoinfo = JSON.parse(JSON.stringify(value[i].VALUE));
              let isDownload = videoinfo.fileName || videoinfo.isDownLoad;
              // zk0205新增，获取收藏列表的时候查本地数据库拿到路径，将isdownload赋值给当前收藏视频的播放选项
              let tableName =
                value[i].TYPE == "1"
                  ? this.sqlTable.messageList
                  : this.sqlTable.privateList;
              let result = tools.operationalDatabase(
                `SELECT isDownLoad FROM ${tableName} WHERE messageId='${value[i].MESSAGE_ID}';`,
                1
              );
              if (result.list.length > 0) {
                //zk0205新增，查到结果修改VLUE的isdownload和fileName,针对检测文件是否存在时异常
                isDownload = result.list[0].isDownLoad;
                videoinfo.isDownLoad = isDownload;
                videoinfo.fileName = isDownload;
                value[i].VALUE = JSON.stringify(videoinfo);
              }
              this.pushPlayerOptions(videoinfo.messageId, isDownload);
            }
          }
          // 一次存到本地 每次上线只获取一次
          tools.operationalDatabase(
            `DELETE FROM ${this.sqlTable.collectList};`
          ); //zk1215新增，每次获取时先清空表，针对重登之后已被删除的不会消失
          value.map((item) => {
            item.VALUE = item.VALUE.replace(/'/g,"''");
            let isKey = tools.operationalDatabase(
              `SELECT MESSAGE_ID FROM ${this.sqlTable.collectList} WHERE MESSAGE_ID = '${item.MESSAGE_ID}';`,
              1
            );
            if (isKey.list.length > 0) return;
            tools.operationalDatabase(
              `REPLACE INTO ${this.sqlTable.collectList}(CREATEDATE,FILE_ID,FILE_TYPE,FROM_ID,FROM_NAME,ID,ISDONE,IS_REMIND,MESSAGE_ID,REMIND_TIME,TYPE,USER_ID,VALUE)
              VALUES('${item.CREATEDATE}','${item.FILE_ID}','${item.FILE_TYPE}','${item.FROM_ID}','${item.FROM_NAME}','${item.ID}','${item.ISDONE}','${item.IS_REMIND}','${item.MESSAGE_ID}','${item.REMIND_TIME}','${item.TYPE}','${item.USER_ID}','${item.VALUE}');`
            );
          });
          this.$refs.isMycollection.collectSearchFn();
        }
      });
    },
    // 获取我的待办
    getRemind() {
      getRemindAll({
        userid: this.myInfo.id,
      })
        .then((res) => {
          if (res.result == 200) {
            this.getOfficial();
            let remind = res.data.list || [];
            // 我的待办定时器提醒
            let remindTimeARR = remind.filter(
              (item) =>
                this.$newDateGetTime(item.REMIND_TIME) >
                this.$newDateGetTime() && item.ISDONE == 0
            );
            if (this.intervaleARR.length > 0) {
              this.intervaleARR.map((item) => {
                clearInterval(item);
              });
            }
            console.log(remindTimeARR, 6486);
            if (remindTimeARR.length > 0) {
              for (let i in remindTimeARR) {
                let remindUUID = this.remindStr + i;
                this.intervaleARR.push(
                  (remindUUID = setInterval(() => {
                    if (
                      this.$newDateGetTime() ==
                      this.$newDateGetTime(remindTimeARR[i].REMIND_TIME)
                    ) {
                      // 新增添加右下角标提醒
                      // 参数(id,type,value,headUrl,sendName,headType)
                      this.messageTips(
                        "remind",
                        "",
                        remindTimeARR[i].value || remindTimeARR[i].VALUE,
                        "",
                        "待办提醒",
                        "6",
                        remindTimeARR[i].ID || remindTimeARR[i].oId
                      );
                      this.noticeList.push(remindTimeARR[i]); // 添加到待办提醒数组
                      console.log(this.noticeList, 6508);
                      this.updateIsDone(remindTimeARR[i]); // 更改完成状态
                      clearInterval(remindUUID);
                    }
                  }, 1000))
                );
              }
            }
          } else {
            this.$Message.warning("查询待办列表失败,请稍后再试");
          }
        })
        .catch((error) => {
          this.$Message.warning("查询待办列表失败,请稍后再试");
        });
    },
    // 新增获取公文列表
    getOfficial() {
      this.$ajax_official(
        "get",
        "office/document/document/myListPage",
        {
          page: 1,
          limit: 1,
        },
        (res) => {
          console.log(res, "公文列表");
          if (res.code == 200) {
            this.officialManageTotal = res.data.undoneSum;
            this.$store.state.officialManageTotal = this.officialManageTotal;
          } else if (res.code == 401) {
            this.$getOfficialToken(this.myInfo);
          } else {
            this.$Message.warning(res.msg);
          }
        },
        (res) => {
          this.$Message.warning(res.msg);
        }
      );
    },
    // 我的待办搜索
    remindSearchFn() {
      this.getRemind();
    },
    // 点击打开待办弹框
    openOfficialBox(item, type = 0) {
      this.$changeTitleColor("", "#fff");
      this.formMsgs = item;
      this.flags = type;
    },

    changeEditor(bol) {
      console.log(bol, 8237);
      this.articleSendList = [];
      this.article_editor_show = bol;
    },
    openLinkFn(articleItem) {
      let url = articleItem.articleUrl || articleItem.url;
      let title = articleItem.articleTitle || articleItem.title || "";
      let res = this.$shell("OpenFormEject", [url, title]);
    },
    revocationArticleFn(articleItem) {
      this.$confirm("是否撤销当前文章？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.deleteArticleInit(articleItem.articleMessage);
          // 通知服务端
          // this.ws.send(
          //   this.$loginJsonString(this.$func.uuid(), "1.500", "1.9.9998", {
          //     type: 2,
          //     sendUserId: this.myInfo.id,
          //     receiveUserId: "",
          //     messageId: articleItem.articleMessage,
          //   })
          // );
          this.$wsSendMsg(
            this.toInfo,
            articleItem.articleMessage,
            "revocation",
            {
              text: this.myInfo.name + " 撤销了一条消息",
              gender: this.myInfo.gender || "1",
              head: this.myInfo.head || "",
              messageId: articleItem.articleMessage,
            },
            this.ws,
            ""
          );
        })
        .catch(() => { });
    },
    // 删除本地数据库的文章
    deleteArticleInit(messageId) {
      tools.operationalDatabase(
        `DELETE FROM ${this.sqlTable.articleList} WHERE articleMessage = '${messageId}';`
      );
      this.$Message.success("删除成功");
      this.$refs.myArticle.articleSearchFn();
    },
    // 删除本地数据库的个人消息
    deletePrivateInit(messageId) {
      this.deleteNowMessage(messageId);
      tools.operationalDatabase(
        `DELETE FROM ${this.sqlTable.privateList} WHERE messageId = '${messageId}';`
      );
    },
    // 删除本地数据库的群消息
    deleteMessageInit(messageId) {
      this.deleteNowMessage(messageId);
      tools.operationalDatabase(
        `DELETE FROM ${this.sqlTable.messageList} WHERE messageId = '${messageId}';`
      );
    },
    // 删除本地数据库的广播
    deleteBroadInit(messageId) {
      console.log(
        "删除本地数据库的广播",
        `DELETE FROM ${this.sqlTable.broadcastList} WHERE messageId = '${messageId}';`
      );
      tools.operationalDatabase(
        `DELETE FROM ${this.sqlTable.broadcastList} WHERE messageId = '${messageId}';`
      );
      this.$refs.myBroadcastnotification.broadSearchFn();
    },
    // 实时删除当前会话消息
    deleteNowMessage(messageId) {
      for (let i in this.currentTempChat[0]) {
        if (this.currentTempChat[0][i].messageId == messageId) {
          this.currentTempChat[0].splice(i, 1);
          break;
        }
      }
      for (let i in this.currentTempChat[1]) {
        if (this.currentTempChat[1][i].messageId == messageId) {
          this.currentTempChat[1].splice(i, 1);
          break;
        }
      }
    },
    workListShow(index) {
      console.log(index, "点击功能列");
      if (index == 5) {
        this.newSearchShow = true;
      } else {
        this.newSearchShow = false;
      }
      // if (index == 12) {
      //   window.open(
      //     this.$store.state.assetApplicationUrl,
      //     "",
      //     "width=1207,height=637"
      //   );
      //   return;
      // }
      // console.log("继续往下执行");
      this.workList.forEach((val) => {
        val.show = false;
      });
      this.$set(this.workList[index], "show", true);
      this.initPage(); //zk1214新增，每次切换时初始化page值
      if (this.workList[1].show && index == 1) {
        const type = "69f175b9-45d3-45e0-87fc-4cbeeff97887";
        // this.$set(this.workList[1],'noRead',0);
        let res = this.$shell("GetInfoUserId", [type]);
        //清除广播闪烁提示
        this.delCurMessageTips(type);
        return;
      }

      if (index == 1) {
        // 初始化广播搜索
        this.$refs.myBroadcastnotification.broadSearchFn();
        let res = this.$shell("GetInfoUserId", [
          "69f175b9-45d3-45e0-87fc-4cbeeff97887",
        ]);
      } else if (index == 3) {
        // this.$proxy('OpenProxy',[this.iframeSrc])
        // window.open(this.iframeSrc)
        this.filesref();
      } else if (index == 4) {
        // this.getCollect();
        //zk1214注释，我的收藏
        // if (this.onlyFirstCollect) {//zk1215修改，每次切换时都会请求收藏列表
        // this.onlyFirstCollect = false; // 点击左侧菜单只执行一次
        // this.getCollect();
        // }
      } else if (index == 5) {
        // 2022/5/26 zc修改 进入待办减少一次请求转到页面加载发送
        // this.getRemind();
        // 新增获取公文的token
        this.$getOfficialToken(this.myInfo);
      } else if (index == 6) {
        this.getSchedule("init");
      } else if (index == 7) {
        this.$nextTick(() => {
          this.$refs.myArticle.articleSearchFn();
        });
      } else if (index == 8) {
        // this.$proxy('OpenProxy',[this.iframeOfficial])
      }
      // 初始化分页
      this.page_num = 1;
      this.files_cur = 1;
      // 初始化待办弹框
      this.isOpenOfficial = false;

      this.$forceUpdate();
    },
    getFileCatalog(id) {
      getFileCatalog_axios({
        pid: id || "",
      })
        .then((res) => {
          this.fileCatalogList = [];
          if (res.result == 200) {
            this.cancelDown();
            if (res.data && res.data.length > 0) {
              var item;
              for (var i = 0; i < res.data.length; i++) {
                item = res.data[i];
                item["ifChoose"] = false;
                this.fileCatalogList.push(item);
              }
            }
          }
        })
        .catch((error) => {
          console.warn(error);
        });
    },
    setWorkListShow(args) {
      console.log("转跳界面" + args[1]);
      this.workListShow(args[1]);
    },
    setStructureList(args) {
      this.setStructureListShow(args[0], args[1]);
    },
    sessionToChat(args) {
      this.toChat(args);
    },
    searchViewShow(tar) {
      this.searchToView(tar[0], tar[1]);
    },
    newChat(toinfo) {
      if (this.isOndropHandle) {
        this.$Message.warning("文件处理中,请稍后");
        return;
      }
      console.log(toinfo, "toinfotoinfotoinfo");
      this.continueNewChat(toinfo[0], toinfo[1]);
    },
    qrcodeClose() {
      this.groupCodeShow = false;
      this.appShow = false;
    },
    getSystemConfigure() {
      var data = tools.operationalDatabase(
        `SELECT * FROM system_${this.myInfo.id};`,
        1
      );
      if (data.list && data.list.length > 0) {
        this.$store.commit("set_user_configure", data.list);
        // 新增判断电脑是否操作
        if (this.$store.state.user_configure[0].isLeave == "true") {
          let info = this.$shell("AutoLever", [
            this.$store.state.user_configure[0].isLeave,
            parseInt(this.$store.state.user_configure[0].leaveTime),
          ]);
        }
      }
    },
    editShowFn() {
      this.myCardShow = false;
      this.edit_section_show = !this.edit_section_show;
    },
    congfigItemClick(info) {
      if (info == 0) {
        this.windowStatus = !this.windowStatus;
      } else if (info == 1) {
        this.passwordStatus = !this.passwordStatus;
      }
      // else if (info == 2) {//zk1225注释，版本升级隐藏
      //   this.updateExeShow = !this.updateExeShow;
      // }
      else if (info == 2) {
        //zk1225修改 3 -> 2
        this.clearStatus = !this.clearStatus;
      }
      // else if (info == 3) {
      // 	this.appShow = !this.appShow;
      // }
      else if (info == 3) {
        //zk1225修改 4 -> 3
        this.exitLogin();
      }
      this.config_active = false;
    },
    exitLogin(status) {
      //zk1225，退出登录
      this.$store.state.initStatus = true;
      this.$store.state.password = "";
      this.$store.state.initLogin = true;
      //2022/5/10 zc新增 在登陆页面不显示重获验签提示
      Notification.closeAll();
      //2022/4/15 zc新增退出登录后 关闭NFC读取卡
      if (this.$store.state.icReadDriveOpen) {
        this.$downloadPlug("PluginUpdateAndDownload", [
          "UMP_Plugin_ICReadDrive",
          "MethodList",
          "Close",
          "",
          "",
        ]);
      }
      try {
        this.$store.state.ws.send(
          this.$loginJsonString(this.$func.uuid(), "1.100", "1.1.0049", {})
        );
      } catch (err) { }
      this.$store.commit("set_soketConnect", true);
      window.offlineFn();
      if (status !== 0) {
        console.log("退出登录==>");
        this.$bus.$emit("exitLogin", "退出登录了。。。。。。"); //zk1225新增，通知login页面退出登录了
        this.$shell("SetLoginUser", ["", "", "", "420", "460"]);
        // 退出功能日志
        let args = JSON.stringify({
          type: "SEND",
          socketUrl: `1.100/1.1.0049`,
          args: `userid: [${this.myInfo.id}]`,
        });
        this.$shell("SaveLog", [args]);
        this.$router.replace("/");
      }
      // 新增断开远程服务链接
      let server = this.$remoteControl("DisconnectServer", []);
      // 同屏 退出登录 断开中转服务器 结束同屏
      this.overScreenFn();
    },
    configMain_show() {
      this.appShow = false;
      this.config_active = !this.config_active;
    },
    croppet_cfg() {
      //zk1218标识，上传头像点击确定
      let _this = this;
      this.$refs.cropper.getCropBlob((data) => {
        let form = new FormData();
        form.append("file", data);
        form.append("userId", _this.myInfo.id);
        _this.$upload(
          "api/v1/oim/head/user/upload.do",
          form,
          (res) => {
            console.log(res, "上传头像之后的返回值");
            this.getAndSaveUserInfo();
            if (res.result == 200) {
              _this.cropper_show = false;
              _this.$Message.success("上传头像成功");
            } else {
              _this.$Message.warning(res.msg);
            }
          },
          (res) => {
            console.warn("error");
          }
        );
      });
    },

    // UpdateGroupDetail(info) {// 暂时无用
    // 	this.$ajax('group/getGroupAndUsersById.do', {
    // 		groupid: info.id
    // 	}, (res) => {
    // 		if(res.result==200){
    // 			let data=res.data;
    // 			this.saveGroupInfo(data);
    // 		}
    // 	}, (err) => {

    // 	})
    // },

    chatRecordScroll() {
      let a =
        this.$refs.recordScroll.scrollTop +
        this.$refs.recordScroll.clientHeight -
        100;
      let b = this.$refs.recordScroll.scrollHeight;
      if (b - a <= 100) {
        if (this.record_count < this.chatSearchList.length) {
          this.record_count += 20;
          this.chatSearchList.push({
            receiveId: 1,
            sendId: 1,
            name: 1,
            value: 1,
            gender: 1,
            time: 1,
            head: "",
            type: "text",
            duration: 1,
            isDownLoad: 1,
            messageId: 1,
            DownLoadId: 1,
          });
          this.chatSearchList.pop();
          this.$forceUpdate();
        }
      }
    },
    //视图在广播页面更新广播消息
    updateBroad() {
      setTimeout(() => {
        let res = tools.operationalDatabase(
          `SELECT a.*,b.* FROM ${this.sqlTable.broadcastList} AS a,${this.sqlTable.userInformation} AS b WHERE a.broadSendId = b.id ORDER BY time DESC;`,
          1
        );
        this.broadList = res.list;
        for (let i = 0; i < this.broadList.length; i++) {
          if (
            this.broadList[i].attachName &&
            this.broadList[i].attachName != ""
          ) {
            let attachName = this.broadList[i].attachName.split(",");
            let attachsize = this.broadList[i].attachsize.split(",");
            let attach = this.broadList[i].attachsize.split(",");
            if (attachName.length > 0) {
              this.broadList[i].files = [];
              for (let j = 0; j < attachName.length; j++) {
                this.broadList[i].files.push({
                  attachName: attachName[j],
                  attachsize: attachsize[j],
                  attach: attach[j],
                });
              }
            }
          } else {
            this.broadList[i].files = [];
          }
        }
        this.$forceUpdate();
      }, 3000);
    },
    //群已读未读列表
    readView(readData, activeIndex, currentItem) {
      if (currentItem.messageId) {
        //zk新增，本地暂存，用于已读和已下载的切换
        this.currentItem = currentItem;
      }
      this.read_info_show = true;
      // this.read_info_show=!this.read_info_show;//zk注释，框已经遮住了文字，已经无法再点击到该按钮
      this.activeIndex = activeIndex; //zk新增，激活谁
      this.group_read = 0;
      this.group_unread = 0;
      this.readUsers = [];
      this.unreadUsers = [];
      if (readData && readData != "undefined") {
        let data = JSON.parse(readData);
        let readUsers = [];
        let unreadUsers = [];
        if (data.readUsers && data.readUsers != "") {
          readUsers = data.readUsers.split(",");
        }
        if (data.unreadUsers && data.unreadUsers != "") {
          unreadUsers = data.unreadUsers.split(",");
        }
        if (this.group_detail.users.length > 0) {
          this.group_detail.users.forEach((i) => {
            if (unreadUsers.indexOf(i.ID) > -1) {
              this.unreadUsers.push(i);
            }
            if (readUsers.indexOf(i.ID) > -1) {
              this.readUsers.push(i);
            }
          });
        }
        this.group_read = this.readUsers.length;
        this.group_unread = this.unreadUsers.length;
      } else {
        this.group_read = 0;
        this.group_unread = this.group_detail.users.length - 1;
        this.unreadUsers = [].concat(this.group_detail.users);
      }
      // 新增下载头像
      let arr = this.group_detail.users.slice(0, 50);
      arr.map((item) => {
        this.downLoadHeadPath(item);
      });
    },
    //个人聊天查询
    searchChat(value) {
      this.chatSearchList = [];
      let id = this.toInfo.id;
      let isTrue = this.toInfo.isGroup == "1";
      var str;
      if (value) {
        if (isTrue) {
          str = `${isTrue ? this.sqlTable.messageList : this.sqlTable.privateList
            } WHERE value LIKE '%${value}%' AND (receiveId='${id}' OR sendId='${id}') AND (time>='${this.start_time ? Number(this.start_time) : 0
            }' AND time<='${this.end_time
              ? Number(this.end_time) + 86400 * 1000
              : new Date().getTime()
            }')`;
        } else {
          str = `${isTrue ? this.sqlTable.messageList : this.sqlTable.privateList
            } WHERE value LIKE '%${value}%' AND (${isTrue ? `receiveId='${id}'` : `sendId='${id}' OR receiveId='${id}'`
            }) AND (time>='${this.start_time ? Number(this.start_time) : 0
            }' AND time<='${this.end_time
              ? Number(this.end_time) + 86400 * 1000
              : new Date().getTime()
            }')`;
        }
      } else {
        str = `${isTrue ? this.sqlTable.messageList : this.sqlTable.privateList
          } WHERE (${isTrue ? `receiveId='${id}'` : `sendId='${id}' OR receiveId='${id}'`
          }) AND (time>='${this.start_time ? Number(this.start_time) : 0
          }' AND time<='${this.end_time
            ? Number(this.end_time) + 86400 * 1000
            : new Date().getTime()
          }')`;
      }
      let res = tools.operationalDatabase(
        `SELECT * FROM  ${str} ORDER BY time DESC;`,
        1
      ); //limit 20
      let len = res.list.length;
      for (let i = 0, len = res.list.length; i < len; i++) {
        res.list[i].value = this.setHistoryMsg(res.list[i]);
      }
      this.chatSearchList = res.list;
      if (this.toInfo.isGroup == "1") {
        getGroupAndUsersById({
          groupid: id,
        }).then((msg) => {
          if (msg.result == 200) {
            msg = msg.data;
            let userList = msg.users || [];
            for (let i = 0; i < this.chatSearchList.length; i++) {
              for (let j = 0; j < userList.length; j++) {
                if (this.chatSearchList[i].sendId == userList[j].ID) {
                  this.chatSearchList[i].name = userList[j].NAME;
                  this.chatSearchList[i].head = userList[j].HEAD;
                }
              }
            }
          }
        });
      }
      this.$forceUpdate();
    },
    //添加成员
    addMember() {
      this.viewTargetShow = false;
      this.viewTarget = null;
      this.setModalFirst(4);
    },
    //获取成员信息
    getMemberInfo(e, item, isGroup) {
      if (isGroup == "0") {
        return;
      }
      this.getGroupUserInfo(e, item, isGroup);
    },
    //获取群成员/个人信息
    getGroupUserInfo(e, item, isGroup) {
      let type = item.type;
      this.viewTargetInfo = true;
      this.getUserInfo(item.id || item.ID || item.sendId, (res) => {
        let id = item.id || item.ID || item.sendId;
        if (res.result == 200) {
          console.log("返回的个人信息", res);
          let info = res.data;
          let job = info.jobtitle == null ? "" : info.jobtitle;
          let department =
            info.departmentname == null ? "" : info.departmentname;
          let userHead = info.head == null ? "" : info.head;
          // 2022/6/17 重新修改账号信息避免账号为空
          this.$set(item, "account", res.data.account);
          let req = tools.operationalDatabase(
            `REPLACE INTO ${this.sqlTable.userInformation
            }(id,name,gender,head,account,jobtitle,department,isAdmin,radioOf,groupOf,nickname) VALUES('${info.id
            }','${info.name}','${info.gender ? info.gender : "1"}','${info.head
            }','${info.account}','${info.jobtitle}','${info.departmentname}','${info.isAdmin
            }','${info.radioOf}','${info.groupOf}','${info.nickname}');`
          );
          if ((item.head || item.HEAD) != userHead) {
            if (userHead == "") {
              tools.operationalDatabase(
                `UPDATE ${this.sqlTable.userInformation} SET head="" WHERE id='${id}';`
              );
            } else {
              this.$set(item, "head", userHead);
              tools.operationalDatabase(
                `UPDATE ${this.sqlTable.userInformation} SET head='${userHead}' WHERE id='${id}'`
              );
              // 6/17 新增，头像不同则下载头像并更新头像内容
              this.downLoadHeadPath(item);
              if (this.myInfo.id == id)
                this.$store.state.myInfo.head = userHead;
              for (let i in this.sessionList) {
                if (this.sessionList[i].id == id) {
                  this.$set(this.sessionList[i], "head", userHead);
                }
              }
            }
          }
          if (isGroup == "1") {
            if ((item.head || item.HEAD) != userHead) {
              for (let i = 0; i < this.chatList.length; i++) {
                for (let j = 0; j < this.chatList[i].length; j++) {
                  if (id == this.chatList[i][j].sendId) {
                    this.$set(this.chatList[i][j], "head", userHead);
                  }
                }
              }
            }
            Object.assign(item, info);
            this.$set(item, "type", type);
          } else {
            if (id == this.toInfo.id && info.head) {
              this.toInfo.head = info.head;
            }
            Object.assign(
              item,
              { jobtitle: info.jobtitle },
              { mobile: info.mobile },
              { departmentname: info.departmentname },
              { email: info.email },
              { employeeno: info.employeeno },
              { departmentnames: info.departmentnames },
              { telephone: info.telephone }
            );
          }
          this.getCurCoor(e);
          this.viewTargetShow = true;
          this.viewTarget = item;
          this.isLinkman();
        }
      });
    },
    //删除群成员（zk注释未被引用）
    deleteGroupUsers(item, index) {
      if (this.my_position == "1" || this.my_position == "2") {
        this.viewTarget = null;
        this.viewTargetShow = false;
        delMember_axios({
          userid: this.myInfo.id,
          fuserid: item.ID,
          groupid: this.toInfo.id,
        }).then((res) => {
          if (res.result == 200) {
            this.group_detail.users.splice(index, 1);
          }
          this.$forceUpdate();
        });
      }
    },
    createSystemTable(id) {
      var xx = tools.operationalDatabase(
        `CREATE TABLE IF NOT EXISTS ${this.sqlTable.systemTable}(_id INTEGER PRIMARY KEY AUTOINCREMENT,notify CHAR(60),warningTone CHAR(60),notice CHAR(60),id CHAR(60),setFont CHAR(200));`
      );
      var insertMinimized = tools.operationalDatabase(
        `ALTER TABLE ${this.sqlTable.systemTable} ADD minimized CHAR(60) NULL;`
      );
      var insertIsLeave = tools.operationalDatabase(
        `ALTER TABLE ${this.sqlTable.systemTable} ADD isLeave CHAR(60) NULL;`
      );
      var insertIsleaveTime = tools.operationalDatabase(
        `ALTER TABLE ${this.sqlTable.systemTable} ADD leaveTime CHAR(60) NULL;`
      );
      var insertConversation = tools.operationalDatabase(
        `ALTER TABLE ${this.sqlTable.systemTable} ADD conversation CHAR(60) NULL;`
      );
      var insertBootlogin = tools.operationalDatabase(
        `ALTER TABLE ${this.sqlTable.systemTable} ADD bootlogin CHAR(60) NULL;`
      );
      var insertBootlogin = tools.operationalDatabase(
        `ALTER TABLE ${this.sqlTable.systemTable} ADD setFont CHAR(200) NULL;`
      );
    },
    systemInit() {
      var systeminit = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.systemTable};`,
        1
      );

      if (systeminit.list.length) {
        if (systeminit.list[0].minimized === "true") {
          let rep = this.$shell("MinimizeToPalletArea", ["0"]);
        } else {
          let rep = this.$shell("MinimizeToPalletArea", ["1"]);
        }
        this.$store.state.user_configure[0].notify = systeminit.list[0].notify
          ? systeminit.list[0].notify
          : false;
        this.$store.state.user_configure[0].notice = systeminit.list[0].notice
          ? systeminit.list[0].notice
          : false;

        //加载系统字体,默认样式不储存
        if (
          systeminit.list[0].setFont !=
          '{"size":14,"color":"#000","bold":"normal"}'
        ) {
          this.$store.state.font_configure = systeminit.list[0].setFont;
        }
      } else {
        var xx = tools.operationalDatabase(
          `REPLACE INTO ${this.sqlTable.systemTable}(notify,warningTone,notice,id,minimized) VALUES('true','false','true','${this.myInfo.id}','true');`
        );
        let rep = this.$shell("MinimizeToPalletArea", ["0"]);
        this.$store.state.user_configure[0].notify = false;
        this.$store.state.user_configure[0].notice = false;
      }
    },
    setConfirm() {
      tools.operationalDatabase(`DELETE FROM ${this.sqlTable.sessionList};`);
      tools.operationalDatabase(`DELETE FROM ${this.sqlTable.messageList};`);
      tools.operationalDatabase(`DELETE FROM ${this.sqlTable.privateList};`);
      tools.operationalDatabase(`DELETE FROM ${this.sqlTable.broadcastList}`);
      // this.chating=false;//zk注释
      this.setChating(false);
      this.setb4Leave(false);
      this.chatList = [[], []];
      this.toInfo = {};
      this.sessionList = [];
      this.clearStatus = false;
    },
    getAndSaveUserInfo() {
      getUserInfo_axios({
        userid: this.myInfo.id,
      })
        .then((res) => {
          console.log(res, "上传头像之后获取到的用户信息");
          if (res.result == "200") {
            // 新增下载头像

            // this.myInfo.headImage = res.data.head;
            // this.myInfo.headImage = res.data.headImage;

            this.newInfo = res.data;
            let myCloneInfo = JSON.parse(JSON.stringify(this.myInfo));
            myCloneInfo.headImage = res.data.head;
            myCloneInfo.headImage = res.data.headImage;

            // this.downLoadHeadPath(this.myInfo);
            this.downLoadHeadPath(myCloneInfo);

            this.imgLoading = true;
            setTimeout(() => {
              this.$store.commit(
                "setUserInfo",
                Object.assign(res.data, { myHeadPath: "" })
              ); //zk1218修改，将myinfo的修改放到下载完图片之后
              this.imgLoading = false;
            }, 2000);
          }
        })
        .catch((res) => {
          console.warn("error");
        });
    },
    fileChange(e) {
      //zk1218标记，触发修改头像
      console.log("开始修改头像");
      if (!e.target.files[0].size) return;
      var _this = this;
      let fileInfo = e.target.files[0];
      var AllImgExt = ".jpg|.jpeg|.bmp|.png|.swf|.gif|.tiff";
      var extName = fileInfo.name
        .substring(fileInfo.name.lastIndexOf("."))
        .toLowerCase(); //（把路径中的所有字母全部转换为小写）
      if (AllImgExt.indexOf(extName + "|") == -1) {
        _this.$Message.warning("请上传正确图片类型");
        return;
      }
      let fileReader = new FileReader();
      fileReader.onload = function (w) {
        let base64 = w.target.result;
        _this.option.img = base64;
        _this.cropper_show = true;
      };
      fileReader.readAsDataURL(fileInfo);
      document.getElementById("head_file").value = "";
    },

    get_top_boolean(id) {
      return !!this.setaList[id];
    },
    get_audio_url(url) {
      url = url.replace(
        "http://172.16.66.101:12000/",
        "http://59.56.179.50:12000/"
      );
      return url;
    },
    //查看个人信息
    chat_view_target(e) {
      if (this.toInfo.isGroup == 1) {
        return;
      } else {
        this.viewTargetInfo = true;
        console.log("当前个人信息", this.toInfo);
        this.getGroupUserInfo(e, this.toInfo);
      }
      this.$forceUpdate();
    },
    set_sure_state(state) {
      let initid = this.$func.uuid();
      this.personalStatus = 5;
      this.ws.send(
        this.$publicSend(initid, "1.101", "1.1.0008", { status: 5 })
      );
      this.cur_state = state;
      this.state_show = false;
    },
    cancel_state_update() {
      let initid = this.$func.uuid();
      this.ws.send(
        this.$publicSend(initid, "1.101", "1.1.0008", { status: 1 })
      );
      this.cur_state = "";
      this.state_input_value = this.cur_state;
      this.personalStatus = 0;
      this.state_show = false;
    },
    check_state_value(i) {
      //zk1215标识，切换在线状态，不同在线状态自动回复的内容不一样
      console.log("第", i);
      console.log("个人状态", this.personalStatus);
      let value = "";
      let flag = this.personalStatus;
      let initid = this.$func.uuid();
      if (i != 4) {
        // 离线后点击上线/其他状态需先发送登录请求
        if (flag == 4) {
          window.reconnection();
          this.$Message.warning({
            content: "离线重连中，请稍等",
            duration: 3,
          });
          setTimeout(() => {
            this.$store.state.ws.send(
              this.$loginJsonString(this.$func.uuid(), "1.100", "1.1.0001", {
                loginData: this.$store.state.loginInfo,
              })
            );
            this.$bus.$emit("startLogin", "重发心跳");
            let userStatus = "1";
            switch (i) {
              case 0:
                userStatus = "1";
                break;
              case 1:
                userStatus = "4";
                break;
              case 2:
                userStatus = "3";
                break;
              case 3:
                userStatus = "6";
                break;
            }
            this.$store.commit("Updated_User_Status", userStatus);
            this.personalStatus = i;
            this.reload();
            // 2022/6/27 重登后拉取离线
            this.$getOffline();
            this.getSessionList();
          }, 3000);
        } else {
          if (i == 0) {
            this.ws.send(
              this.$publicSend(initid, "1.101", "1.1.0008", { status: 1 })
            );
            //window.offlineFn()
          } else if (i == 1) {
            value = "忙碌中,稍后联系您..";
            this.ws.send(
              this.$publicSend(initid, "1.101", "1.1.0008", { status: 4 })
            );
          } else if (i == 2) {
            value = "离开会儿,稍后联系您..";
            this.ws.send(
              this.$publicSend(initid, "1.101", "1.1.0008", { status: 3 })
            );
          } else if (i == 3) {
            value = "会议中,稍后联系您..";
            this.ws.send(
              this.$publicSend(initid, "1.101", "1.1.0008", { status: 6 })
            );
          }
        }
      } else {
        this.exitLogin(0);
        value = "离线";
      }
      if (flag !== 4) {
        this.personalStatus = i;
      }
      this.cur_state = value;
      this.state_show = false;
    },
    get_audio_realPath(url) {
      let reg = /\\/g;
      let res = url.replace(/\\/g, "/");
      res = res.replace("http:", "http://");
      return res;
    },
    showMap(item) {
      this.show_map = !this.show_map;
      this.mapData = item;
    },
    broadDelete() {
      let res = tools.operationalDatabase(
        `DELETE FROM ${this.sqlTable.broadcastList} WHERE messageId='${this.broadList[this.broad_show_item_index].messageId
        }';`
      );
      this.broadList.splice(this.broad_show_item_index, 1);
      this.broad_show_item = null;
      this.$forceUpdate();
    },
    // 当前页第一条、最后一条时查询上页、下页广播
    searchBroadList(type) {
      let page = 1;
      let pageAll = Math.ceil(this.broadTotal / this.pageSize);
      if (type == "upPage" && this.files_cur > 1) {
        page = this.files_cur - 1;
        this.$refs.myBroadcastnotification.broadSearchFn();
      } else if (type == "downPage" && this.files_cur < pageAll) {
        page = this.files_cur + 1;
        this.$refs.myBroadcastnotification.broadSearchFn();
      }
    },
    // 点击查询的上页、下页广播
    newPageFn(type) {
      let pageAll = Math.ceil(this.broadTotal / this.pageSize);
      if (type == "upPage" && this.files_cur > 1) {
        this.files_cur--;
        this.$refs.myBroadcastnotification.broadSearchFn();
        this.broad_show_item_index = this.broadList.length - 1;
      } else if (type == "downPage" && this.files_cur < pageAll) {
        this.files_cur++;
        this.$refs.myBroadcastnotification.broadSearchFn();
        this.broad_show_item_index = 0;
      }
      this.broadList[this.broad_show_item_index].isRead = 1;
      tools.operationalDatabase(
        `UPDATE ${this.sqlTable.broadcastList
        } SET isRead = '1' WHERE messageId='${this.broadList[this.broad_show_item_index].messageId
        }';`
      );
    },
    openBroadItem(item) {
      this.detailShow = true;
      this.search_broad_show_item = true;
      this.searchTargetShow = false;
      this.recordshow = false;
      item.isRead = 1;
      let arr = this.$utilJs.initBroadFile([item]);
      this.searchBroadItem = arr[0];
      tools.operationalDatabase(
        `UPDATE ${this.sqlTable.broadcastList} SET isRead = '1' WHERE messageId='${this.searchBroadItem.messageId}';`
      );
    },
    // 点击当前广播
    setBroadItem(item) {
      console.log("当前广播", item);
      let pageAll = Math.ceil(this.broadTotal / this.pageSize);
      // if (item.index == 0 && item.index == (this.broadList.length - 1)) {
      //   // 有且只有一页
      //   if (this.files_cur == 1) {
      //     this.$store.commit("setBroadType", "noShow");
      //   }else if (this.files_cur == pageAll) {// 最后一页只有一条时
      //     this.$store.commit("setBroadType", "showUpPage");
      //   }
      // } else {
      if (item.index == this.broadList.length - 1) {
        this.$store.commit("setBroadType", "downPage");
        // 当前为最后一页最后一条时
        if (this.files_cur == pageAll) {
          this.$store.commit("setBroadType", "noShow");
        }
      } else if (item.index == 0 && this.files_cur != 1) {
        this.$store.commit("setBroadType", "upPage");
        // 当前为第一页第一条时
        if (this.files_cur == 1) {
          this.$store.commit("setBroadType", "noShow");
        }
      }
      // }
      this.broad_show_item = item.item;
      this.broad_show_item_index = item.index;
      tools.operationalDatabase(
        `UPDATE ${this.sqlTable.broadcastList} SET isRead = '1' WHERE messageId='${this.broad_show_item.messageId}';`
      );
      //this.broadSearchFn();
      this.$forceUpdate();
    },
    // 上一条 下一条
    pageIndex(index) {
      this.broad_show_item_index = index;
      tools.operationalDatabase(
        `UPDATE ${this.sqlTable.broadcastList} SET isRead = '1' WHERE messageId='${this.broadList[index].messageId}';`
      );
      this.$refs.myBroadcastnotification.broadSearchFn();
      this.$forceUpdate();
    },

    // 筛选标题-筛选时间(文章)
    articleTitleTimeFn(index) {
      this.articleTitleTime = index;
      this.initPage();
    },
    deleteBroadItem(item) {
      this.broad_show_item = item.item;
      this.broad_show_item_index = item.index;
      this.broadDelete();
      this.$forceUpdate();
    },
    //清除聊天记录
    clear_records() {
      let res = null;
      if (this.toInfo.isGroup == 1) {
        res = tools.operationalDatabase(
          `DELETE FROM ${this.sqlTable.messageList} WHERE receiveId='${this.toInfo.id}'`
        );
      } else {
        res = tools.operationalDatabase(
          `DELETE FROM ${this.sqlTable.privateList} WHERE receiveId='${this.toInfo.id}' OR sendId='${this.toInfo.id}'`
        );
      }
      if (res.success == "true") {
        this.$Message.info("清除数据成功！");
        this.chatList = [[], []];
        for (let i = 0, len = this.sessionList.length; i < len; i++) {
          if (this.sessionList[i].id == this.toInfo.id) {
            this.$set(this.sessionList[i], "type", "text");
            this.$set(this.sessionList[i], "value", "");
          }
        }
      }
      this.currentTempChat = [[], []];
      this.$forceUpdate();
    },
    //共享文件下载
    downShareFile(item) {
      let _this = this;
      let initid = this.$func.uuid();
      item.messageId = initid;
      this.downloadList.push(item);
      let index = item.NAME.lastIndexOf("/");
      let str = item.NAME.substring(index + 1, item.NAME.length);
      let fileName = str.lastIndexOf("."); //取到文件名开始到最后一个点的长度
      let fileNameLength = str.length; //取到文件名长度
      let fileFormat = str.substring(fileName + 1, fileNameLength); //截
      let info = _this.$shell("SaveFileUrl", [
        _this.myInfo.id,
        this.$store.state.url + "api/v1/oim/file/download.do?id=" + item.FILEID,
        item.messageId,
        str,
        fileFormat,
        "",
      ]);
      info = JSON.parse(info);
      if (info.return_code == "TRUE") {
        this.$Message.success("文件下载中,请稍后");
        this.$set(item, "loading", true);
      }
    },
    toDownImg(item) {
      let _this = this;
      this.$downLoad(
        "api/v1/oim/image/download.do",
        item.DownLoadId,
        (wt) => {
          var fileReader = new FileReader();
          fileReader.onload = function (w) {
            let suffix = item.value.split(".").splice(-1)[0];
            let base64 = w.target.result.replace(
              /^data\:.{1,40}base64\,/gi,
              ""
            );
            let info = _this.$shell("SaveFileStream", [
              _this.myInfo.id,
              base64,
              suffix,
            ]);
            info = JSON.parse(info);
            if (info.return_code == "TRUE") {
              _this.$shell("SaveAS", [
                info.return_msg,
                item.DownLoadId + "." + suffix,
              ]);
            }
          };
          fileReader.readAsDataURL(wt);
        },
        (wt) => {
          console.warn("error", wt);
        }
      );
    },
    //点击下载文件
    toDownFile(item, type) {
      // console.log(this.myInfo, this.toInfo, "发送人，接收人信息");
      if (!type && !type == 1) {
        if (!item.DownLoadId) {
          // this.$Message.warning("文件上传中,请稍后下载");
          this.$Message.warning("文件上传失败,请联系对方重新发送");
          return;
        }
        if (item.loading) {
          this.$Message.warning("下载中,请稍后");
          return;
        }
      }
      this.downloadList.push(item);
      let index = item.value.lastIndexOf("/");
      let str = item.value.substring(index + 1, item.value.length);
      let fileName = str.lastIndexOf("."); //取到文件名开始到最后一个点的长度
      let fileNameLength = str.length; //取到文件名长度
      let fileFormat = str.substring(fileName + 1, fileNameLength); //截
      let path =
        this.$store.state.user_hot_key[5].charAt(
          this.$store.state.user_hot_key[5].length - 1
        ) == "\\"
          ? this.$store.state.user_hot_key[5]
          : this.$store.state.user_hot_key[5] + "\\";
      let paramsStr; //zk新增，查询参数
      let isTrue = this.toInfo.isGroup == "1";
      if (isTrue) {
        //zk124修改判断条件
        if (this.toInfo.id.length < 20) {
          console.error(this.toInfo, "群对象错误");
        }
        //群聊
        paramsStr = `id=${item.DownLoadId}&messageKey=${item.messageId}&userId=${this.myInfo.id}&fromid=${item.sendId}&fromname=${item.name}&groupId=${this.toInfo.id}`;
      } else {
        //单聊
        paramsStr = `id=${item.DownLoadId}&messageKey=${item.messageId}&userId=${item.receiveId}&fromid=${item.sendId}&fromname=${item.name}`;
      }
      console.log(paramsStr, "查询参数");
      let info;
      let DownLoadPath =
        item.DownLoadId.indexOf("http") != -1
          ? item.DownLoadId
          : this.$store.state.url + "api/v1/oim/file/download.do?" + paramsStr;
      console.log(DownLoadPath, "下载地址");
      if (type && type == 1) {
        info = this.$shell("SaveFileUrl", [
          this.myInfo.id,
          DownLoadPath,
          item.messageId,
          str,
          fileFormat,
          "",
        ]);
      } else {
        info = this.$shell("SaveFileUrl", [
          this.myInfo.id,
          DownLoadPath,
          item.messageId,
          str,
          fileFormat,
          path,
        ]);
      }
      info = JSON.parse(info);
      if (info.return_code == "TRUE") {
        this.$Message.success("文件下载中,请稍后");
        this.$set(item, "upload", 1);
        this.$set(item, "progress", 0);
        console.timeEnd("下载时间");
        this.$set(item, "loading", true);
        this.$refs.homeChatMain.updateInterface();
        this.$forceUpdate();
      }
    },
    // 2022/6/8 转发本地文件存储文件地址
    toForwardingLocalData(data) {
      this.$set(this.toForwardingLocal, "address", data);
    },
    //转发功能
    toForwarding(item) {
      console.log(item, this.modalTitle, "转发的内容");
      this.chatChooseList = [item];
      if (this.modalTitle != 2) {
        this.resetModalFirst();
      }
      //转发本地文件
      if (item == 1) {
        this.isToForwardingLocal = true;
      } else {
        this.isToForwardingLocal = false;
      }
      this.forwardMsg = "";
      this.modalTitle = 2;
      this.modalFirst = true;
    },
    //处理系统发送群聊报文
    setSystemGroup(id, cate, rName, rId, sName, gName, offline, text = "") {
      let str = offline ? "" : "1.1.100";
      let sysValue = "";
      // setTimeout(() => {
      //   this.getGroupUser();
      // }, 3000); //zk调试，延时有问题，踢出群在延时结束之后才生效
      if (id == this.myInfo.id) {
        if (cate == str + "1") {
          sysValue = `你邀请 ${rName} 加入了 ${gName}`;
        } else if (cate == str + "2") {
          sysValue = `你将 ${rName} 移出了  ${gName}`;
        } else if (cate == str + "3") {
          sysValue = `你解散了 ${gName}`;
          this.group_info_show = false;
        } else if (cate == str + "5") {
          sysValue = text;
        }
      } else if (rId == this.myInfo.id) {
        if (cate == str + "1") {
          sysValue = `你被 ${sName} 邀请加入了 ${gName}`;
        } else if (cate == str + "2") {
          sysValue = `你被 ${sName} 移出了 ${gName}`;
        } else if (cate == str + "3") {
          sysValue = `${sName} 解散了 ${gName}`;
          this.group_info_show = false;
        } else if (cate == str + "5") {
          sysValue = text;
        }
      } else {
        if (cate == str + "1") {
          sysValue = `${rName} 被 ${sName} 邀请加入了 ${gName}`;
        } else if (cate == str + "2") {
          sysValue = `${rName} 被 ${sName} 移出了 ${gName}`;
        } else if (cate == str + "3") {
          sysValue = `${sName} 解散了 ${gName}`;
          this.group_info_show = false;
        } else if (cate == str + "5") {
          sysValue = text;
        }
      }
      console.log("群聊报文处理结果", sysValue);
      return sysValue;
    },
    //处理文字报文
    setTextMsg(value) {
      return this.toExpression(this.$utilJs.regUrl(value));
    },
    //处理历史数据
    setHistoryMsg(item) {
      if (item.type == "text") {
        let value = this.toExpression(this.$utilJs.regUrl(item.value));
        // value = `<div style="font-size:${
        //   item.fontSize ? item.fontSize : 14
        // }px">${value}</div>`;
        return value;
      } else if (item.type == "shareGroup") {
        let value = {};
        if (item.value) {
          value = JSON.parse(item.value) || {
            shareGroupName: "信息错误",
            shareGroupId: false,
          };
        } else {
          value = { shareGroupName: "信息错误", shareGroupId: false };
        }
        return value;
      } else if (item.type == "video") {
        this.playerOptions[item.messageId] = {
          playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
          autoplay: false, //如果true,浏览器准备好时开始回放。
          muted: false, // 默认情况下将会消除任何音频。
          loop: false, // 导致视频一结束就重新开始。
          preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
          language: "zh-CN",
          aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
          fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
          sources: [
            {
              type: "",
              src: this.$isRelativePath(item.isDownLoad), //视频url地址
            },
          ],
          poster: "", //你的封面地址
          notSupportedMessage: "此视频暂无法播放，请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
          controlBar: {
            timeDivider: true,
            durationDisplay: true,
            remainingTimeDisplay: false,
            fullscreenToggle: true, //全屏按钮
          },
        };
      } else {
        return item.value;
      }
    },
    //修改文本内容发送给后台
    textMsg(myMsg) {
      let regLess = /(\<div\>\<br\>\<\/div\>)*$/g; //去除末尾无意义换行
      myMsg = myMsg.replace(regLess, "");
      let reg = /\<img src=['"]static(.+?)\>/g; //匹配图片
      var imgArr = myMsg.match(reg);
      var regx = /\d+\.gif/g; //匹配gif
      var a = [];
      var sendToAndior = myMsg;
      if (imgArr) {
        for (let i = 0, len = imgArr.length; i < len; i++) {
          let sdn = imgArr[i].match(regx);
          let ins = parseInt(sdn[0].replace(".gif", "")); //获取图片数字
          a.push(ins);
        }
        for (let i = 0, len = imgArr.length; i < len; i++) {
          //找到图片描述
          let m = Math.floor(a[i] / 36);
          let q = a[i] % 36;
          sendToAndior = sendToAndior.replace(
            imgArr[i],
            "[" + this.expression[m][q] + "]"
          );
        }
      }
      //找到非<br>div
      let regAdd = /\<div\>[^\<]*\<\/div\>/g;
      let addArr = Array.from(new Set(sendToAndior.match(regAdd)));
      for (let i in addArr) {
        let arrtest = addArr[i].replace(/-/g, "/-/");
        let regh = new RegExp(arrtest, "gim");
        let regDiv = /\<div\>|\<\/div\>/g;
        let str = addArr[i].replace(regDiv, "");
        sendToAndior = sendToAndior.replace(regh, str);
      }
      return sendToAndior;
    },
    //处理表情
    toExpression(str) {
      var reg = /\[[\u4e00-\u9fa5]+\]/g;
      var num = [];
      var imageArr = str.match(reg);
      var imageTrue = [];
      var newArr = [].concat.apply([], this.expression);
      if (imageArr) {
        for (let i = 0, len = imageArr.length; i < len; i++) {
          for (let j = 0, lens = newArr.length; j < lens; j++) {
            if (new RegExp(newArr[j]).test(imageArr[i])) {
              num.push(this.$utilJs.createFaceImage(j));
              imageTrue.push(imageArr[i]);
              break;
            }
          }
        }
        for (let i in imageTrue) {
          str = str.replace(imageTrue[i], num[i]);
        }
      }
      return str;
    },
    //聊天列表生成
    generateMsg(type, value, msgId, duration, isDownLoad, DownLoadId) {
      return {
        type: type,
        value: value,
        messageId: msgId,
        sendId: this.myInfo.id,
        sendName: this.myInfo.name,
        name: this.myInfo.name,
        receiveId: this.toInfo.id,
        receiveName: this.toInfo.name,
        isGroup: this.toInfo.isGroup,
        time: new Date().getTime(),
        duration: duration,
        isRead: "1",
        isSuccessSend: "1",
        isDownLoad: isDownLoad,
        DownLoadId: DownLoadId,
      };
    },
    self_update_session(type, value, id, dura, time) {
      for (let i in this.sessionList) {
        if (this.sessionList[i].id == this.toInfo.id) {
          this.sessionList[i].value = value;
          this.sessionList[i].duration = dura;
          this.sessionList[i].type = type;
          this.sessionList[i].messageId = id;
          this.sessionList[i].time = time;
        }
      }
    },
    //输入框获取焦点事件
    content_input_focus() {
      this.faceShow = false;
      this.group_info_show = false;
      this.files_show = false;
      this.read_info_show = false;
      this.deleteIcon = false;
      this.config_active = false; //左下角设置
    },
    // closeCornal
    closeCornal() {
      this.quotationsShow = false;
    },

    // 查看全部语录
    allQuotations() {
      this.flagHeadType = 7;
      // 查询我的群组
      getGroupByUserId({ userid: this.myInfo.id }).then((res) => {
        if (res.result == 200) {
          this.textGroupList = res.data;
          this.selectedGroupId = this.toInfo.id;
          this.quotationsList = this.allQuotationsList;
        }
      });
      this.allText = true;
    },
    toGroupFunction(index, activeRecords) {
      if (index == 1) {
        // 聊天记录
        this.files_show = false;
        this.group_info_show = false;
        this.quotationsShow = false;
        this.flagHeadType = 1;
        if (activeRecords) {
          if (this.activeRecords) {
            this.personal_chat_list = false;
          }
          this.activeRecords = !this.activeRecords;
        } else {
          this.personal_chat_list = !this.personal_chat_list;
        }
        if (this.activeRecords && activeRecords) {
          this.chatSearch = "";
          this.start_time = null;
          this.end_time = null;
          this.personal_chat_list = !this.personal_chat_list;
          this.searchChat();
        }
      } else if (index == 0) {
        this.messageFree = !this.messageFree;
        this.updateMessageFree();
      } else if (index == 2) {
        // 打开群设置
        if (this.group_info_show) {
          this.group_info_show = false;
          return;
        }
        let info = tools.operationalDatabase(
          `SELECT * FROM ${this.sqlTable.groupList} WHERE id='${this.toInfo.id}';`,
          1
        );
        let users = tools.operationalDatabase(
          `SELECT * FROM ${this.sqlTable.groupUsers} WHERE groupId='${this.toInfo.id}';`,
          1
        );
        let arr = info.list[0];
        let arr1 = users.list;
        this.topChat = this.get_top_boolean(this.toInfo.id); //是否置顶
        this.messageFree = this.free_icon_sign(this.toInfo.id); //免打扰
        this.files_show = false;
        console.log("打开群设置");
        this.group_info_show = true;
        this.group_info = arr;
        this.getGroupAndUsers(this.toInfo.id);
      } else {
        // 重点语录
        this.files_show = false;
        this.group_info_show = false;
        this.activeRecords = false;
        this.personal_chat_list = !this.personal_chat_list;
        this.flagHeadType = 6;
        let key = this.toInfo.id;
        let pageData = {
          pageNumber: 1,
          pageSize: 30,
        };
        this.ws.send(
          this.$publicSend(key, "1.500", "1.1.2008", {
            groupId: this.toInfo.id,
            page: pageData,
          })
        );
        this.quotationsShow = !this.quotationsShow;
      }
    },
    specified(res) {
      //zk注释，未被调用
      //点击@群发去除自身
      this.group_people = [];
      for (let i in this.group_detail.users) {
        if (this.group_detail.users[i].ID != this.myInfo.id) {
          this.group_people.push(this.group_detail.users[i]);
          this.$forceUpdate();
        }
      }
      this.specifield_istrue = res;
      this.quickShow = false;
      this.faceShow = false;
      this.specified_show = !this.specified_show;
    },
    updateSessionMessageFree(value) {
      this.messageFree = value[0];
      this.getDisturb();
      this.$forceUpdate();
    },
    //免打扰设置显示
    free_icon_sign(id) {
      for (let i in this.free_list) {
        if (this.free_list[i].userId == id) {
          return true;
        }
      }
      return false;
    },
    // 新增获取消息免打扰
    getDisturb() {
      getUserDnd({
        userId: this.myInfo.id,
        objectId: "",
      })
        .then((res) => {
          // console.log(res, "获取到的免打扰人员"); //zk1217注释
          if (res.result === 200) {
            for (let item of res.data) {
              item.userId = item.OBJECTID;
            }
            this.free_list = res.data;
            this.$forceUpdate();
          }
        })
        .catch((error) => {
          console.warn(error, "err==>获取消息免打扰");
        });
    },
    //免打扰设置
    updateMessageFree(value, id) {
      this.messageFree = value;
      this.getDisturb();
      this.$forceUpdate();
    },
    //修改置顶
    updateTopChat(e) {
      let path = `user/${e ? "add" : "del"}SetaTop.do`;
      let type = this.toInfo.isGroup == 1 ? "2" : "1";
      universal_axios(path, {
        userid: this.myInfo.id,
        type: type,
        objectId: this.toInfo.id,
        sort: "0",
      }).then((res) => {
        // this.getSetaTop();//放到1.2.0013
      });
    },
    //关闭群信息
    close_group_info() {
      this.group_info_show = !this.group_info_show;
      this.$forceUpdate();
    },
    //会话删除
    toDelChat(item) {
      let tableName =
        this.toInfo.isGroup == "1"
          ? this.sqlTable.messageList
          : this.sqlTable.privateList;
      let result = tools.operationalDatabase(
        `DELETE FROM ${tableName} WHERE messageId='${item.messageId}';`
      );
      if (result.success == "true") {
        for (let j = 0; j < this.chatList.length; j++) {
          for (let k = 0; k < this.chatList[j].length; k++) {
            if (item.messageId == this.chatList[j][k].messageId) {
              this.chatList[j].splice(k, 1);
            }
          }
        }
        //zk127新增，同时删除currenttempchat
        for (let j = 0; j < this.currentTempChat.length; j++) {
          for (let k = 0; k < this.currentTempChat[j].length; k++) {
            if (item.messageId == this.currentTempChat[j][k].messageId) {
              this.currentTempChat[j].splice(k, 1);
            }
          }
        }
      }
      for (let i = 0, len = this.sessionList.length; i < len; i++) {
        if (this.sessionList[i].id == this.toInfo.id) {
          if (this.chatList[0].length > 0) {
            let type = this.chatList[0][0].type;
            let value =
              type == "GPS"
                ? "[位置]"
                : type == "file"
                  ? "[文件]"
                  : type == "audio"
                    ? "[语音]"
                    : type == "image"
                      ? "[图片]"
                      : type == "video"
                        ? "[视频]"
                        : type == "shareGroup"
                          ? "[群分享]"
                          : this.chatList[0][0].value;
            this.$set(this.sessionList[i], "value", value || "");
            this.$forceUpdate();
          } else if (this.chatList[1].length > 0) {
            let type = this.chatList[1][0].type;
            let value =
              type == "GPS"
                ? "[位置]"
                : type == "file"
                  ? "[文件]"
                  : type == "audio"
                    ? "[语音]"
                    : type == "image"
                      ? "[图片]"
                      : type == "video"
                        ? "[视频]"
                        : type == "shareGroup"
                          ? "[群分享]"
                          : this.chatList[1][0].value;
            this.$set(this.sessionList[i], "value", value || "");
            this.$forceUpdate();
          } else {
            this.$set(this.sessionList[i], "value", "");
            this.$forceUpdate();
          }
        }
      }
      this.$forceUpdate();
    },
    //改变sessionList已选择
    setSessionListCheck(id, isSystem) {
      for (let i in this.sessionList) {
        this.$set(this.sessionList[i], "checked", false);
        if (this.sessionList[i][isSystem ? "systemId" : "id"] == id)
          this.$set(this.sessionList[i], "checked", true);
      }
      this.$forceUpdate();
    },

    //收到消息之后,sessionList+chatlist改变
    updateSessionChat(
      sId,
      rId,
      sName,
      rName,
      text,
      time,
      isGroup,
      keys,
      type,
      duration,
      url,
      DownLoadId,
      replay,
      fontSize,
      rGender,
      rHead,
      isAdd = true
    ) {
      fontSize = fontSize ? fontSize : "14";
      // console.log(sId, rId, sName, rName, text, time, isGroup, keys, type, duration, url,DownLoadId,fontSize,rGender,'=>收到消息之后')
      // 当前会话
      console.log('updateSessionChat',[this.myInfo.id,this.toInfo.id,sId,rId])
      if (this.myInfo.id == sId && rId == this.toInfo.id) {
        let isTrue = sId == this.toInfo.id;
        this.updateSessionList(
          rId,
          text,
          time,
          isTrue,
          isGroup,
          rName,
          type,
          1,
          sId,
          rGender,
          rHead,
          isAdd
        );
        if (isTrue) {
          if (type == "article") {
            // 新增分享文章
            this.insertChatList(
              sId,
              rId,
              sName,
              text,
              this.myInfo.gender,
              this.myInfo.head,
              time,
              keys,
              type,
              duration,
              url,
              DownLoadId,
              fontSize,
              replay
            );
          } else {
            this.insertChatList(
              sId,
              rId,
              sName,
              type != "image" && type != "file" && type != "GPS"
                ? type == "text"
                  ? this.setTextMsg(`${text}`)
                  : text
                : text,
              this.myInfo.gender,
              this.myInfo.head,
              time,
              keys,
              type,
              duration,
              url,
              DownLoadId,
              fontSize,
              replay
            );
          }
        }
      }
      else {
        // 非当前会话
        let nId = rId == this.myInfo.id ? sId : rId;
        let nName = rId == this.myInfo.id ? sName : rName;
        this.updateSessionList(
          nId,
          text,
          time,
          nId == this.toInfo.id,
          isGroup,
          nName,
          type,
          0,
          sId,
          rGender,
          rHead,
          isAdd
        );
        if (sId == this.toInfo.id || rId == this.toInfo.id) {
          let userInfo = this.getSqlUserInfo(sId);
          let sex = userInfo[0] ? userInfo[0].gender : "1";
          let headpath = userInfo[0] ? userInfo[0].head : "";
          console.log("当前群聊界面");
          if (isGroup == this.toInfo.isGroup) {
            if (!this.activeWindowState || this.workIndex != 0) {
              //zk新增，窗体激活但不在聊天时也会往未读数组中添加this.workIndex != 0
              if (isGroup == "1") {
                this.unreadMuster.push({
                  keys: keys,
                  sendUserId: sId,
                  receiveUserId: this.myInfo.id,
                  groupId: this.toInfo.id,
                });
              } else {
                this.unreadMuster.push({
                  keys: keys,
                  sendUserId: this.toInfo.id,
                  receiveUserId: this.myInfo.id,
                  timestamp: new Date().getTime(),
                });
              }
              console.log(this.unreadMuster, "新增的未读消息");
            } else {
              if (isGroup == "1") {
                console.log("当前群聊界面222");
                this.ws.send(
                  this.$publicSend(keys, "1.500", "1.1.2005", {
                    sendUserId: sId,
                    receiveUserId: this.myInfo.id,
                    groupId: this.toInfo.id,
                  })
                );
              } else {
                let initKey = this.$func.uuid();
                this.ws.send(
                  this.$publicSend(keys, "1.500", "1.1.1014", {
                    sendUserId: this.toInfo.id,
                    receiveUserId: this.myInfo.id,
                    timestamp: new Date().getTime(),
                    isServiceAcc: this.myInfo.authCustservice,
                  })
                );
              }
            }
            if (type == "article") {
              // 新增分享文章
              this.insertChatList(
                sId,
                rId,
                sName,
                text,
                sex,
                headpath,
                time,
                keys,
                type,
                duration,
                url,
                DownLoadId,
                fontSize
              );
            } else {
              this.insertChatList(
                sId,
                rId,
                sName,
                type != "image" && type != "file" && type != "GPS"
                  ? type == "text"
                    ? this.setTextMsg(`${text}`)
                    : text
                  : text,
                sex,
                headpath,
                time,
                keys,
                type,
                duration,
                url,
                DownLoadId,
                fontSize,
                replay
              );
            }
          }
        }
      }
      //聊天框滚动
      if(this.myInfo.id == rId && sId == this.toInfo.id){
        this.$forceUpdate()
        if(this.$refs['homeChatMain']){
          this.$refs['homeChatMain'].scrollToLower()
        }
      }
    },
    //当前聊天记录添加聊天消息
    insertChatList(
      sId,
      rId,
      name,
      value,
      gender,
      headpath,
      time,
      keys,
      type,
      duration,
      url,
      DownLoadId,
      fontSize,
      replay,
      small = "",
      raw = ""
    ) {
      //zk新增小图small和原图raw，默认为空,zk注释，这里也会走unshift
      let next = false;
      if (type == "shareGroup") {
        value = JSON.parse(value);
      }
      fontSize = fontSize ? fontSize : "14";
      for (let i in this.currentTempChat) {
        //zk129新增，撤销消息更新到currenttempchat
        for (let j in this.currentTempChat[i]) {
          if (this.currentTempChat[i][j].messageId == keys) {
            // 2022/5/16 zc修改 图片下载后重新渲染
            if (type == "image") {
              this.currentTempChat[i][j].value = value;
            }
            if (DownLoadId) {
              this.currentTempChat[i][j].DownLoadId = DownLoadId;
            }
            if (type == "revocation") {
              Object.assign(this.currentTempChat[i][j], {
                value: value,
                type: type,
              });
            }
            // next = true;
            // return;//zk1215注释，此时不return，等到修改了chatlist再return，且修改两个表的顺序不能变动，因为翻页后currenttempchat中可能查不到消息就无法走到return
          }
        }
      }

      for (let i in this.chatList) {
        for (let j in this.chatList[i]) {
          if (this.chatList[i][j].messageId == keys) {
            // 2022/5/16 zc修改 图片下载后重新渲染
            if (type == "image") {
              this.chatList[i][j].value = value;
            }
            if (DownLoadId) {
              this.chatList[i][j].DownLoadId = DownLoadId;
            }
            if (type == "revocation") {
              console.log("更新撤回聊天消息");
              Object.assign(this.chatList[i][j], { value: value, type: type });
            }
            next = true;

            console.log(
              this.currentTempChat,
              this.chatList,
              "进入更新聊天界面"
            );
            return;
          }
        }
      }

      if (!next) {
        if (type == "announcement") {
          //群公告后端未传头像信息,头像进行匹配
          if (this.group_detail.users && this.group_detail.users.length > 0) {
            for (let i = 0; i < this.group_detail.users.length; i++) {
              if (sId == this.group_detail.users[i].ID) {
                headpath = this.group_detail.users[i].HEAD;
              }
            }
          }
        }
        // 新增下载头像
        this.downLoadHeadPath({
          id: sId,
          head: headpath,
        });
        if (sId == this.myInfo.id) {
          let isServiceAcc = this.isService ? 1 : 0;
        }
        console.log(value, 8569);
        this.chatList[0].unshift({
          id: sId, // 新增匹配头像的ID
          receiveId: rId,
          sendId: sId,
          name: name,
          value:
            type == "text"
              ? `${value}`
              : type == "article"
                ? JSON.stringify(value)
                : value,
          gender: gender,
          time: time,
          head: headpath,
          isSuccessSend: "0", // 新增发送状态的标识
          type: type,
          duration: duration,
          isDownLoad: url,
          messageId: keys,
          DownLoadId: DownLoadId,
          fontSize: fontSize,
          replay: replay,
          smallValue: small, //zk新增，chatlist新增小图属性
          rawValue: raw, //zk新增，chatlist新增原图属性
        });
        //console.log(sId, rId, this.myInfo.id);
        if (!this.havenext) {
          //zk新增，只有当前显示聊天内容到达底部，才会往temp中push或者自己是接收人
          this.currentTempChat[0].push({
            //zk新增，新消息往tempchat0中push
            id: sId, // 新增匹配头像的ID
            receiveId: rId,
            sendId: sId,
            name: name,
            value:
              type == "text"
                ? `${value}`
                : type == "article"
                  ? JSON.stringify(value)
                  : value,
            gender: gender,
            time: time,
            head: headpath,
            isSuccessSend: "0", // 新增发送状态的标识
            type: type,
            duration: duration,
            isDownLoad: url,
            messageId: keys,
            DownLoadId: DownLoadId,
            fontSize: fontSize,
            replay: replay,
            smallValue: small, //zk新增，chatlist新增小图属性
            rawValue: raw, //zk新增，chatlist新增原图属性
          });

          JSON.parse(JSON.stringify(this.currentTempChat[0]), 8623);
          // 取消排序消息
          // this.currentTempChat[0].sort(function(a, b) {
          //   return a.time - b.time;
          // });
          // console.log(this.currentTempChat, 8512);
        }
      }
    },
    contextmenu(e, item) {
      let rect = e.target.getBoundingClientRect();
      this.offsetTop = rect.top;
      this.offsetLeft = rect.left + 60;
      this.currentCheckItem = item;
      this.minorShow = true;
    },
    /**
     * 1.3.1002获取离线消息
     * @param {string} userId 发送人
     * @param {string} type 1个人 2群 3广播 5日程 6待办
     * @param {number} times 当前循环次数，由服务端+1
     * @param {string} farBack 0五天内离线 1五天前的离线
     */
    getOffline(userId, type, total, times, farBack = "0") {
      if (parseInt(times) > 20 || !total) {
        return;
      }
      console.log("获取离线消息", userId, type, total, times, farBack);
      this.ws.send(
        this.$loginJsonString(this.$func.uuid(), "1.500", "1.3.1002", {
          content: {
            font: {
              underline: false,
              bold: false,
              italic: false,
              color: "000000",
              name: "Microsoft YaHei",
              size: 14,
            },
            sections: [
              {
                items: [
                  {
                    type: "",
                    value: "",
                  },
                ],
              },
            ],
            timestamp: new Date().getTime(),
          },
          userId: userId, //resultArray[i].sendId
          receiveId: this.$store.state.myInfo.id,
          times: times,
          type: type, //resultArray[i].type,
          total: total, //resultArray[i].value
          farBack: farBack, //如果传0，和原来的接口一样;如果传1，获取5天前的
        })
      );
    },
    //获取消息时修改sessionList
    updateSessionList(
      id,
      value,
      time,
      isNow,
      isGroup,
      name,
      type,
      isRead,
      sId,
      gender,
      head,
      isAdd
    ) {
      console.log(id, value, isAdd, 8675);
      for (let i in this.sessionList) {
        if (this.sessionList[i].id == id) {
          if (!this.sessionList[i].isAite) {
            if (type == "article") value = JSON.stringify(value);
            this.$set(this.sessionList[i], "value", value);
          }
          if (
            type == "text" &&
            (value.indexOf("@所有人") != -1 ||
              value.indexOf("@" + this.myInfo.name) != -1) &&
            this.toInfo.id != id
          ) {
            this.$set(this.sessionList[i], "isAite", true);
          }
          this.$set(this.sessionList[i], "time", time);
          this.$set(this.sessionList[i], "type", type);
          this.$set(this.sessionList[i], "isRead", isRead);
          this.$set(this.sessionList[i], "sendId", sId);
          // 重新设置sessionList的值
          this.$set(this.sessionList[i], "value", value);
          if (
            !isNow &&
            (this.$store.state.user_configure[0].notify === "true" ||
              this.$store.state.user_configure[0].notify == "")
          ) {
            if (sId != this.myInfo.id) {
              const num = parseInt(this.sessionList[i].noRead);
              if (type == "revocation") {
                //撤回消息，未读数量-1
                this.$set(
                  this.sessionList[i],
                  "noRead",
                  num - 1 <= 0 ? 0 : num - 1
                );
              } else {
                if (isAdd) {
                  this.$set(this.sessionList[i], "noRead", num + 1);
                }
              }
            }
          }
          this.sortSessionList();
          return;
        }
      }
      // 新增下载头像
      this.downLoadHeadPath({
        id: sId,
        head: head,
      });
      if (name != "" && id != "") {
        this.sessionList.unshift({
          sendId: sId,
          id: id,
          value: value,
          time: time,
          isGroup: isGroup,
          name: name,
          noRead: sId == this.myInfo.id ? 0 : 1,
          type: type,
          isRead: isRead,
          head: head,
          gender: gender, // 新增解决第一次登录默认头像显示错误的问题
        });
        this.sortSessionList();
      }
      if (isGroup != 1) {
        getUserInfo_axios({
          userid: id,
        })
          .then((res) => {
            if (res.result == 200) {
              for (let i = 0; i < this.sessionList.length; i++) {
                if (this.sessionList[i].id == id) {
                  this.sessionList[i].head = res.data.head || "";
                }
              }
            }
          })
          .catch((res) => {
            console.log(res, "err=>");
          });
      }
    },
    // 消息提示
    messageTips(
      id,
      type,
      value,
      headUrl,
      sendName,
      headType,
      messageId = "",
      number = ""
    ) {
      console.log(
        id,
        type,
        value,
        headUrl,
        sendName,
        headType,
        messageId,
        "角标闪烁参数"
      );
      if (this.$store.state.user_configure[0].warningTone === "true") {
        let res = this.$shell("PlayInfoSound", []);
      }

      if (this.free_icon_sign(id)) {
        return;
      }
      /**
       * 判断传入的头像类型
       * @param {string} headType
       * 0：自定义头像
       * 1：旧单人默认头像 已废弃
       * 2：群头像
       * 3：广播通知头像
       * 4：单人男默认头像
       * 5：单人女默认头像
       * 6：我的待办头像
       * 7：我的日程头像
       */
      let htype = null;
      switch (parseInt(headType)) {
        case 0:
          htype = "0";
          break;
        case 1:
          htype = "2";
          break;
        case 3:
          htype = "3";
          break;
        case 4:
          htype = "4";
          break;
        case 5:
          htype = "5";
          break;
        case 6:
          htype = "6";
          break;
        case 7:
          htype = "7";
          break;
        default:
          break;
      }
      //判断是否为自定义头像
      // if(headUrl!=""&&headUrl!='null'&&headUrl!=null&&headUrl!='0'&&htype!='2'&&htype!='3'&&htype!='6'&&htype!='7') {
      // 	htype='0';
      // };
      if (!this.$isNull(headUrl)) htype = "0";
      let headInfo = "";
      if (htype == "0") {
        let isPath = tools.operationalDatabase(
          `SELECT headPathID FROM ${this.sqlTable.headPathList} WHERE id = '${id}';`,
          1
        );
        if (isPath.list.length > 0) headInfo = isPath.list[0].headPathID;
        else {
          let item = {
            id: id,
            head: headUrl,
          };
          //新增下载头像
          this.downLoadHeadPath(item);
          let data = tools.operationalDatabase(
            `SELECT headPathID FROM ${this.sqlTable.headPathList} WHERE id = '${id}';`,
            1
          );
          if (data.list.length > 0) headInfo = data.list[0].headPathID;
        }
      }
      //是否存在当前提醒对象
      if (!this.messageTipsArr) {
        this.messageTipsArr = {};
      }
      let hasId = id in this.messageTipsArr;
      if (!hasId) {
        this.messageTipsArr[id] = [];
      }
      //撤回处理
      if (type == "revocation") {
        if (this.messageTipsArr[id].length > 0) {
          this.messageTipsArr[id].forEach((item, index) => {
            if (item[5] == messageId) {
              this.messageTipsArr[id].splice(index, 1);
              if (this.messageTipsArr[id].length == 0) {
                delete this.messageTipsArr[id];
              }
              this.showTips();
            }
          });
        }
        return;
      }


      //去重
      if (this.messageTipsArr[id].length > 0) {
        console.log(this.messageTipsArr, messageId, 8792);
        let exist = this.messageTipsArr[id].some((i) => i[5] == messageId);
        if (exist) {
          console.log("遇到重复了");
          return;
        }
      }

      if (this.free_list.length > 0) {
        for (let i = 0; i < this.free_list.length; i++) {
          if (this.free_list[i].userId == id) {
            return;
          }
        }
        //数量由前端判断
        this.messageTipsArr[id].push([
          id,
          headInfo,
          htype,
          sendName,
          type == "GPS"
            ? "[位置]"
            : type == "file"
              ? "[文件]"
              : type == "audio"
                ? "[语音]"
                : type == "image"
                  ? "[图片]"
                  : type == "video"
                    ? "[视频]"
                    : type == "shareGroup"
                      ? "[群分享]"
                      : type == "screen"
                        ? "[同屏]"
                        : type == "article"
                          ? "[文章]"
                          : type == "assect"
                            ? "[资产]"
                            : value
                              ? value.replace(/<[^<>]+>|&nbsp;/g, "").trim()
                              : "",
          messageId,
          number ? number : hasId ? this.messageTipsArr[id].length + 1 : 1,
          "getNewInfo",
        ]);
      } else {
        //数量由前端判断
        this.messageTipsArr[id].push([
          id,
          headInfo,
          htype,
          sendName,
          type == "GPS"
            ? "[位置]"
            : type == "file"
              ? "[文件]"
              : type == "audio"
                ? "[语音]"
                : type == "image"
                  ? "[图片]"
                  : type == "video"
                    ? "[视频]"
                    : type == "shareGroup"
                      ? "[群分享]"
                      : type == "screen"
                        ? "[同屏]"
                        : type == "article"
                          ? "[文章]"
                          : value
                            ? value.replace(/<[^<>]+>|&nbsp;/g, "").trim()
                            : "",
          messageId,
          number ? number : hasId ? this.messageTipsArr[id].length + 1 : 1,
          "getNewInfo",
        ]);
      }


      console.log(this.messageTipsArr, messageId, 9615);


      if (
        this.$store.state.user_configure[0].notice !== "true" &&
        this.$store.state.user_configure[0].notice != ""
      ) {
        return;
      }
      this.showTips();

    },
    //会话列表排序
    sortSessionList() {
      // zk1214新增sessionlist去重
      let temp = [];
      for (let i in this.sessionList) {
        let flag = true;
        for (let j in temp) {
          if (this.sessionList[i].id == temp[j].id) {
            flag = false;
          }
        }
        if (flag) {
          temp.push(this.sessionList[i]);
        }
      }
      this.sessionList = temp;

      let _this = this;
      let obj = {
        time: 0,
      };
      if (this.sessionList.length == 1) {
        //会话列表为1的情况
        let aaa = this.sessionList[0];
        if (_this.get_top_boolean(this.sessionList[0].id)) {
          _this.$set(aaa, "sort", 1);
        } else {
          _this.$set(aaa, "sort", 0);
        }
      } else {
        this.sessionList.sort(function (a, b) {
          let x = parseInt(a.time);
          let y = parseInt(b.time);
          if (a.isRead == 0 && x > obj.time) obj = a;
          if (b.isRead == 0 && y > obj.time) obj = b;
          let m = 0,
            n = 0;
          if (_this.get_top_boolean(a.id)) {
            m = 1;
            _this.$set(a, "sort", 1);
          } else {
            m = 0;
            _this.$set(a, "sort", 0);
          }
          if (_this.get_top_boolean(b.id)) {
            n = 1;
            _this.$set(b, "sort", 1);
          } else {
            n = 0;
            _this.$set(b, "sort", 0);
          }
          return n - m || y - x;
        });
      }
      if (obj.time != 0 && this.firstTip) {
        if (
          this.$store.state.user_configure[0].notice !== "true" ||
          this.$store.state.user_configure[0].notice != ""
        ) {
          return;
        }
        let headType = "0";
        let headInfo =
          "";
        if (obj.head != "" && obj.head != "null" && obj.head != null) {
          headType = "0";
        } else {
          headType = "1";
          headInfo =
            "";
        }
        if (obj.isGroup == "1") {
          headType = "2";
          headInfo =
            "";
        }
        if (obj.broadSendId) {
          headType = "3";
          headInfo =
            "";
        }
        let hasId = id in this.messageTipsArr;
        if (!hasId) {
          this.messageTipsArr[id] = [];
        }
        if (this.free_list.length > 0) {
          for (let i = 0; i < this.free_list.length; i++) {
            if (this.free_list[i].userId == obj.id) {
              return;
            }
          }
          //数量由前端判断
          this.messageTipsArr[id].push([
            obj.id || obj.broadSendId,
            headType == "0" ? this.$get_inline_head(obj.head) : headInfo,
            headType,
            obj.name,
            obj.type == "article"
              ? "[分享文章]"
              : obj.type == "GPS"
                ? "[位置]"
                : obj.type == "file"
                  ? "[文件]"
                  : obj.type == "audio"
                    ? "[语音]"
                    : obj.type == "image"
                      ? "[图片]"
                      : obj.type == "video"
                        ? "[视频]"
                        : obj.type == "shareGroup"
                          ? "[群分享]"
                          : obj.value.replace(/<[^<>]+>|&nbsp;/g, "").trim(),
            0,
            hasId ? this.messageTipsArr[id].length : 1,
            "getNewInfo",
          ]);
        } else {
          //数量由前端判断
          this.messageTipsArr[id].push([
            obj.id || obj.broadSendId,
            headType == "0" ? this.$get_inline_head(obj.head) : headInfo,
            headType,
            obj.name,
            obj.type == "article"
              ? "[分享文章]"
              : obj.type == "GPS"
                ? "[位置]"
                : obj.type == "file"
                  ? "[文件]"
                  : obj.type == "audio"
                    ? "[语音]"
                    : obj.type == "image"
                      ? "[图片]"
                      : obj.type == "video"
                        ? "[视频]"
                        : obj.type == "shareGroup"
                          ? "[群分享]"
                          : obj.value.replace(/<[^<>]+>|&nbsp;/g, "").trim(),
            0,
            hasId ? this.messageTipsArr[id].length : 1,
            "getNewInfo",
          ]);
        }
      }
      // console.log("闪烁，会话列表排序");
      // this.showTips()
      this.firstTip = false;
      this.$forceUpdate(); //zk注释，刷新机制
    },
    //常用联系人|我的群组->聊天
    toNewChat(item, isGroup) {
      this.searchResultShow = false;
      console.log("常用联系人|我的群组", JSON.stringify(item), isGroup);
      if (this.clickIntervale) {
        window.clearTimeout(this.clickIntervale);
        this.clickIntervale = null;
      }
      this.clickIntervale = setTimeout(() => {
        if (this.isOndropHandle) {
          this.$Message.warning("文件处理中,请稍后");
          return;
        }
        this.group_info_show = false;
        this.deleteIcon = false;
        item.id = item.ID || item.id;
        item.name = item.NAME || item.name;
        item.departmentname = item.DEPARTMENTNAME || item.departmentname;
        item.jobtitle = item.JOBTITLE || item.jobtitle;
        if (!isGroup) {
          this.getUserInfo(
            item.id,
            (data) => {
              if (data.result == 200) {
                Object.assign(item, data.data);
                this.viewTarget = item;
                this.viewTargetShow = true;
                this.$forceUpdate();
                let info = data.data || {};
                let ggds = tools.operationalDatabase(
                  `REPLACE INTO ${this.sqlTable.userInformation
                  }(id,name,gender,head,account,jobtitle,department,isAdmin,radioOf,groupOf,nickname) VALUES('${info.id
                  }','${info.name}','${info.gender ? info.gender : "1"}',''${info.head
                  }'','${info.account}','${info.jobtitle}','${info.departmentname
                  }','${info.isAdmin}','${info.radioOf}','${info.groupOf}','${info.nickname
                  }');`
                );
                this.isLinkman();
              }
            },
            (res) => {
              this.viewTarget = item;
              this.viewTargetShow = true;
            }
          );
          this.$forceUpdate();
          return;
        }
        this.setSider(0);
        for (let i in this.sessionList) {
          if (this.sessionList[i].id == item.id) {
            this.toChat(this.sessionList[i]);
            return;
          }
        }
        let group = isGroup ? "1" : "0";
        let time = new Date().getTime();
        tools.createSession(this.sqlTable);
        tools.createMessage(this.sqlTable);
        tools.operationalDatabase(
          `REPLACE INTO ${this.sqlTable.sessionList}(userId,isGroup,time) VALUES ('${item.id}','${group}','${time}');`
        );
        isGroup
          ? this.getGroupDetail(item.id, true)
          : this.insertUser(item.id, 1);
        let obj = Object.assign(item, {
          value: "",
          time: time,
          isGroup: group,
        });
        this.sessionList.unshift(obj);
        this.toChat(this.sessionList[0]);
        this.sortSessionList();
      }, 300);
    },
    searchMdbTochat(item) {
      this.isListSider = true;
      this.searchResultShow = false;
      if (item.isGroup == 1 && isNaN(item.id)) {
        //zk120新增，针对搜索结果跳聊天
        this.dbtoNewChat(item, true);
      } else {
        this.dbtoNewChat(item, false);
      }
    },
    dbtoNewChat(item, isGroup) {
      if (this.clickIntervale) {
        window.clearTimeout(this.clickIntervale);
        this.clickIntervale = null;
      }
      if (item.ID) item.id = item.ID;
      if (this.isOndropHandle) {
        this.$Message.warning("文件处理中,请稍后");
        return;
      }
      this.group_info_show = false;
      this.deleteIcon = false;
      this.viewTargetShow = false;
      this.setSider(0);
      //会话列表有置顶时排序修改
      let sortArr = this.sessionList.filter((val) => {
        return val.sort == 1;
      });
      for (let i in this.sessionList) {
        if (this.sessionList[i].id == item.id) {
          let obj = this.sessionList[i];
          this.sessionList.splice(i, 1);
          if (obj.sort == 1) {
            this.sessionList.unshift(obj);
          } else {
            this.sessionList.splice(sortArr.length, 0, obj);
          }
          this.toChat(obj);
          return;
        }
      }
      let group = isGroup ? "1" : "0";
      let time = new Date().getTime();
      tools.createSession(this.sqlTable);
      tools.createMessage(this.sqlTable);
      tools.operationalDatabase(
        `REPLACE INTO ${this.sqlTable.sessionList}(userId,isGroup,time) VALUES ('${item.id}','${group}','${time}');`
      );
      isGroup
        ? this.getGroupDetail(item.id, true)
        : this.insertUser(item.id, 1);
      let obj = Object.assign(item, {
        value: "",
        time: time,
        isGroup: group,
      });
      this.sessionList.unshift(obj);
      this.toChat(this.sessionList[0]);
      this.sortSessionList();
    },
    //他人信息到聊天
    continueNewChat(item, isGroup, searchInfo, isSearch) {
      console.log(item, isGroup, searchInfo, isSearch, "他人信息到聊天");
      if (item.ID) item.id = item.ID;
      this.searchResultShow = false;
      // this.chating=true;//zk注释
      this.setChating(true);
      this.setb4Leave(true);
      this.setSider(0);
      if (isGroup == "broad") {
        this.setSider(2, true);
        this.$set(this.workList[1], "show", true);
        this.broad_show_item = item;
        return;
      }
      if (isGroup) {
        if (isGroup && isSearch) {
          item.id = searchInfo.id;
        }
        this.getGroupDetail(item.id, true);
      } else {
        this.insertUser(item.id, 1);
      }
      let sortArr = this.sessionList.filter((val) => {
        return val.sort == 1;
      });
      for (let i in this.sessionList) {
        if (this.sessionList[i].id == item.id) {
          let obj = this.sessionList[i];
          this.sessionList.splice(i, 1);
          if (obj.sort == 1) {
            this.sessionList.unshift(obj);
          } else {
            this.sessionList.splice(sortArr.length, 0, obj);
          }
          this.toChat(obj);
          this.viewTarget = null;
          this.viewTargetShow = false;
          return;
        }
      }
      let group = isGroup ? "1" : "0";
      let time = new Date().getTime();
      let head = item.head || item.HEAD || "";
      let nId = item.id;
      tools.createSession(this.sqlTable);
      tools.createMessage(this.sqlTable);
      let info = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.sessionList} WHERE userId='${nId}';`,
        1
      );
      if (info.list.length == 0)
        tools.operationalDatabase(
          `REPLACE INTO ${this.sqlTable.sessionList}(userId,isGroup,time) VALUES ('${nId}','${group}','${time}');`
        );
      let obj = Object.assign(item, {
        value: "",
        time: time,
        isGroup: group,
      });
      obj.head = head;
      this.sessionList.unshift(obj);
      this.toChat(this.sessionList[0]);
      this.viewTarget = null;
      this.viewTargetShow = false;
      this.sortSessionList();
    },

    //获取用户信息 返回list
    getSqlUserInfo(id) {
      let userInfo = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.userInformation} WHERE id='${id}'`,
        1
      );
      return userInfo.list;
    },

    //移出人员
    delCheckPerson(id) {
      for (let i = 0; i < this.checkPersonArray.length; i++) {
        this.checkPersonArray[i].id == id && this.checkPersonArray.splice(i, 1);
      }
    },

    getGroupUser() {
      getGroupByUserId({
        userid: this.myInfo.id,
      }).then((res) => {
        if (res.data && res.data.length > 0) {
          for (let i = 0; i < res.data.length; i++) {
            res.data[i].isGroup = 1;
          }
        }
        this.groupList = res.data || [];
        console.log(this.groupList, "获取当前人员所有的群聊");
        if (this.toInfo && this.toInfo.isGroup == "1") {
          //zk111标识，收到进群回执1.1.1001，当前聊天的是群，就会判断当前群是不是新加的群
          this.isDissolve = true;
          let id = this.toInfo.id;
          this.groupList.forEach((item) => {
            if (item.id == id) {
              this.isDissolve = false;
            }
          });
        }
      });
    },
    // 获取群列表
    getGroupList() {
      getGroupByUserId({
        userid: this.myInfo.id,
      }).then((res) => {
        this.groupList = res.data || [];
      });
    },
    personItem(index) {
      if (index == 0) {
        this.delLinkman();
      } else if (index == 1) {
        if (this.viewTarget.id == this.myInfo.id) {
          this.$Message.warning("不能添加自己");
          return;
        }
        let data = {
          ownUserId: this.myInfo.id,
          memberUserId: this.viewTarget.id,
        };
        addUserCategoryMember(data).then((info) => {
          if (info.result == 200) {
            this.viewTarget.ifLinkman = true;
            this.viewTargetShow = false;
            this.getUserCategoryNames();
            this.$Message.success("添加联系人成功");
          } else {
            this.$Message.warning(info.msg);
          }
        });
      }
    },
    cardClose(bol) {
      this.viewTargetShow = bol;
    },
    //删除常用联系人
    delLinkman() {
      let GROUPID = "1";
      for (let i = 0; i < this.friendsGroup.length; i++) {
        for (let j = 0; j < this.friendsGroup[i].USER.length; j++) {
          if (
            (this.viewTarget.id || this.viewTarget.ID) ==
            this.friendsGroup[i].USER[j].ID
          ) {
            GROUPID = this.friendsGroup[i].ID;
          }
        }
      }
      let data = {
        userid: this.myInfo.id,
        categoryid: GROUPID,
        fuserid:
          (this.viewTarget.id || this.viewTarget.ID) != this.toInfo.id
            ? this.viewTarget.id || this.viewTarget.ID
            : this.toInfo.id,
      };
      delUserCategoryMember(data).then((info) => {
        if (info.result == 200) {
          this.getUserCategoryNames();
          this.ifLinkman = false;
          this.viewTarget.ifLinkman = false;
          this.viewTargetShow = false;
          this.$Message.success("删除联系人成功");
        } else {
          this.$Message.warning(info.msg);
        }
      });
    },
    isLinkman(p = this.toInfo.id) {
      if (this.viewTarget && this.viewTarget.id == p) {
        this.ifLinkman = false;
      }
      if (this.viewTarget) {
        this.viewTarget.ifLinkman = false;
      }
      for (var k in this.friendsGroup) {
        for (var i = 0; i < this.friendsGroup[k].USER.length; i++) {
          if (
            this.friendsGroup[k].USER[i].ID ==
            (this.viewTarget ? this.viewTarget.id || this.viewTarget.ID : p)
          ) {
            if (this.viewTarget && this.viewTarget.id == p) {
              this.viewTarget.ifLinkman = true;
              this.ifLinkman = true;
            } else {
              if (this.viewTarget) {
                this.viewTarget.ifLinkman = true;
              }
            }
          }
        }
      }
    },
    //添加常用联系人
    addLinkman(i = this.toInfo.id) {
      if (this.myInfo.id == i) {
        this.$Message.warning("不能添加自己");
        return;
      }
      let data = {
        ownUserId: this.myInfo.id,
        memberUserId: i,
      };
      addUserCategoryMember(data).then((info) => {
        if (info.result == 200) {
          this.ifLinkman = true;
          this.viewTargetShow = false;
          this.toInfo.GROUPID = "1";
          this.getUserCategoryNames();
          this.$Message.success("添加联系人成功");
        } else {
          this.$Message.warning(info.msg);
        }
      });
    },
    //单人聊天顶部功能页
    chatFunClick(index) {
      for (let i in this.chatFunArray) {
        this.$set(
          this.chatFunArray[i],
          "active",
          i == index ? !this.chatFunArray[i].active : false
        );
      }
      console.log("0000")
      if (index == 0) {
        //添加常用联系人
        this.addLinkman();
      } else {
        this.group_info_show = !this.group_info_show;
        this.files_show = false;
        this.control_show = false;
      }
      this.$forceUpdate();
    },
    //index --->1为搜索,其他不需要参数
    // operationalDatabase(statements, index) {
    //   let to = JSON.stringify({
    //     Sqlstr: statements,
    //   });
    //   return arguments[1]
    //     ? JSON.parse(this.$shellSQL(to, index))
    //     : JSON.parse(this.$shellSQL(to));
    // },
    //搜索群信息是否存在
    selectGroupInfo(id) {
      return tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.groupList} WHERE id='${id}';`
      );
    },
    //获取群详情并保存
    getGroupDetail(id, wantuse) {
      getGroupAndUsersById({ groupid: id }).then((res) => {
        console.log(res, 9926);
        if (res.result == 200) {
          let msg = res.data;
          console.log(msg, 12288);
          if (wantuse) {
            this.group_detail = msg;
            for (let i = 0; i < this.group_detail.users.length; i++) {
              let user = this.group_detail.users[i];
              if (user.ID == this.myInfo.id) {
                this.my_position = user.POSITION;
                break;
              }
            }
          }
          this.$nextTick(() => {
            this.saveGroupInfo(msg);
            // 新增下载头像
            let users = [];
            if (msg.users.length > 50) {
              users = msg.users.slice(0, 50);
            } else {
              users = msg.users;
            }
            users.map((item) => {
              this.downLoadHeadPath(item);
            });
          });
          // 对群成员进行排序
          this.$groupSort();
          this.$forceUpdate();
        }
      });
    },
    //查询用户是否存在不存在则操作
    searchAndSaveUser(id) {
      let user = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.userInformation} WHERE id='${id}';`,
        1
      );
      if (user.list.length == 0) {
        tools.operationalDatabase(
          `REPLACE INTO ${this.sqlTable.userInformation}(id,name,gender,head,account,jobtitle,department,isAdmin,radioOf,groupOf,nickname) VALUES('${id}','','','','','','','','','','');`
        );
        this.insertUser(id, 0);
      }
    },
    //离线保存信息
    insertOffData(result, msgValue, isGroup, time, rId) {
      console.log(result, msgValue, isGroup, time, rId, "离线保存信息");
      let tableName =
        isGroup == "1" ? this.sqlTable.messageList : this.sqlTable.privateList;
      let userInfo =
        isGroup == "1"
          ? this.sqlTable.groupList
          : this.sqlTable.userInformation;
      let userIds = result;
      if (isGroup == "1") {
        userIds = rId;
      }
      let a = tools.operationalDatabase(
        `REPLACE INTO ${tableName}(name,receiveId,sendId,type,value,time,messageId,isRead,isSuccessSend,isDownLoad,DownLoadId,duration,fontSize,replay) VALUES ${msgValue};`
      );

      let b = tools.operationalDatabase(
        `REPLACE INTO ${this.sqlTable.sessionList}(userId,isGroup,time) VALUES ('${userIds}','${isGroup}','${time}');`
      );

      console.log(a, b, 9651, "存入离线消息到本地");
      if (isGroup == "1") {
        let data = tools.operationalDatabase(
          `SELECT * FROM ${this.sqlTable.groupList} WHERE id='${result}'`,
          1
        );
        if (data.list.length == 0) {
          let msg = {
            id: result,
          };
          tools.operationalDatabase(
            `REPLACE INTO ${this.sqlTable.groupList}(id,name,groupIntroduce,isJoin,head,total) VALUES('${result}','','',"1",'','');`
          );
          this.getGroupDetail(result);
        }
      }
    },
    /**
     * 新增离线撤回消息更改数据库value值
     * @param {Object} item
     * @param {string} isGroup 0个人 1群
     */
    updateOffData(item, isGroup) {
      // console.log(item,isGroup,'测试消息列表未知问题updateOffData')
      if (item.type == "revocation") {
        let tableName =
          isGroup == "1"
            ? this.sqlTable.messageList
            : this.sqlTable.privateList;
        if (item.value)
          tools.operationalDatabase(
            `UPDATE ${tableName} SET value = '${JSON.parse(item.value).text
            }', type = 'revocation' WHERE messageId = '${item.messageId}';`
          );
      }
    },
    //保存群详情
    saveGroupInfo(msg) {
      let introduce = msg.introduce == null ? "" : msg.introduce;
      tools.operationalDatabase(
        `REPLACE INTO ${this.sqlTable.groupList}(id,name,groupIntroduce,isJoin,head,total) VALUES('${msg.id}','${msg.name}','${introduce}',"1",'${msg.head}','${msg.memberToal}');`
      );
      if (this.toInfo && this.toInfo.id == msg.id) {
        //cxr20210825
        this.toInfo.name = msg.name;
      }
      if (this.sessionList) {
        for (let i = 0; i < this.sessionList.length; i++) {
          if (this.sessionList[i].id == msg.id) {
            this.sessionList[i].name = msg.name;
          }
        }
      }
    },

    //获取会话列表最新广播条数
    getSessionBroad() {
      let noRead = this.$refs.myBroadcastnotification.getBroadNoRead()
        ? this.$refs.myBroadcastnotification.getBroadNoRead()
        : 0;
      let broad = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.broadcastList} WHERE isRead='0' ORDER BY time DESC limit 1;`,
        1
      );
      let list = broad.list;
      console.log(list);
      if (
        list[0]
        // list[0].title != "undefined" &&
        // list[0].value != "undefined"
      ) {
        // console.log("获取会话列表最新广播条数", noRead, list[0]);
        this.messageTips(
          "69f175b9-45d3-45e0-87fc-4cbeeff97887",
          "text",
          list[0].title,
          "",
          "广播通知",
          "3",
          list[0]._id,
          noRead
        );
      }
      this.$set(this.workList[1], "noRead", noRead);
      this.broadNoRead = noRead; // 新增左侧功能菜单显示广播未读消息
      this.$store.state.broadNoRead = noRead;
    },
    //群聊单聊 判断表是否存在|不存在则创建，然后插入或修改，接着修改或者插入会话列表时间，最后判断是否存在用户信息不存在获取保存
    insertData(
      sendName,
      toId,
      myId,
      type,
      value,
      time,
      msgId,
      isRead = 0,
      sendding,
      isDown,
      downId,
      duration,
      isGroup,
      fontSize,
      head,
      replay = "",
      isByRead,
      isServiceAcc = 0
    ) {
      console.log(
        "发送人名称：",
        sendName,
        "收件人id：",
        toId,
        "我的id：",
        myId,
        "类型：",
        type,
        "值：",
        value,
        "时间：",
        time,
        "消息id：",
        msgId,
        "是否已读：",
        isRead,
        "发送状态：",
        sendding,
        "是否下载：",
        isDown,
        "下载id：",
        downId,
        "大小：",
        duration,
        "是否群聊：",
        isGroup,
        "字体大小：",
        fontSize,
        "头：",
        head,
        "回复：",
        replay,
        "是否被读：",
        isByRead,
        "是否为客服号：",
        isServiceAcc,
        "09537"
      );
      let rerObject; // 返回对象
      let selectObj;
      let readStatus = isByRead ? 1 : 0;
      let tableName =
        isGroup == "1" ? this.sqlTable.messageList : this.sqlTable.privateList;
      let result = toId == this.myInfo.id ? myId : toId;
      // 新增确认消息已经发送到了服务器=>消息发送成功
      rerObject = tools.operationalDatabase(
        `UPDATE ${tableName} SET isSuccessSend = '0' WHERE messageId = '${msgId}'`
      );
      // selectObj = tools.operationalDatabase(
      //   `SELECT * FROM ${tableName}  WHERE messageId = '${msgId}'`
      // );
      console.log(rerObject, rerObject.success, 9604);
      if (!rerObject.success) {
        return rerObject;
      }
      if (isGroup == "1") {
        tools.createGroup(this.sqlTable);
        if (type == "system") {
          // this.getGroupDetail(result);
        } else {
          let data = tools.operationalDatabase(
            `SELECT * FROM ${this.sqlTable.groupList} WHERE id='${result}'`,
            1
          );
          if (data.list.length == 0) this.getGroupDetail(result);
        }
      }
      if (type == "text") {
        value = value.replace(/\'/gi, "''");
      }
      if (head != 6) {
        if (myId != this.myInfo.id) {
          this.UpDateUser(myId, head, isRead);
        }
      }
      // console.log(sendName, toId, myId, type, value, time, msgId, isRead, sendding, isDown, downId, duration, isGroup, fontSize, head, '==>')
      // 新增判断数据库是否有这条消息
      let isMsgId = tools.operationalDatabase(
        `SELECT COUNT(1) total FROM ${tableName} WHERE messageId='${msgId}'`,
        1
      );
      //zk1214新增，不为撤销消息才return
      console.log("消息插入数据库是否已存在", isMsgId);
      if (
        isMsgId.success &&
        isMsgId.list &&
        isMsgId.list.length > 0 &&
        isMsgId.list[0].total > 0 &&
        type != "revocation"
      ) {
        this.isSaved = false;
        // 2022/5/16 zc新增 如果是图片则更新图片路径实现下载后显示
        if (type == "image") {
          return tools.operationalDatabase(
            `UPDATE ${tableName} SET value = "${value}" WHERE messageId = "${msgId}"`
          );
        }
        // 同步服务器的时间
        return tools.operationalDatabase(
          `UPDATE ${tableName} SET time = "${time}" WHERE messageId = "${msgId}"`
        );
        // retrun
      }
      console.log("没有重复");
      //撤销删除对方本地文件
      if (type == "revocation") {
        let isMsg = tools.operationalDatabase(
          `SELECT * FROM ${tableName} WHERE messageId='${msgId}' AND type = 'file' AND isDownLoad != '0'`,
          1
        );
        if (isMsg.list.length > 0) {
          console.log("别人发的，撤销删除本地文件", isMsg.list[0].isDownLoad);
          let res = this.$shell("DeleteFile", [isMsg.list[0].isDownLoad]);
        }
      }
      if (isGroup == 1) {
        //插入群消息表
        rerObject = tools.operationalDatabase(
          `REPLACE INTO ${tableName}(name,receiveId,sendId,type,value,time,messageId,isRead,isSuccessSend,isDownLoad,DownLoadId,duration,fontSize,replay) VALUES ('${sendName}','${toId}','${myId}','${type}','${value}','${time}','${msgId}','${isRead}','${sendding}','${isDown}','${downId}','${duration}','${fontSize}','${replay}')`
        );
      } else {
        if (myId == this.myInfo.id) {
          isServiceAcc = this.isService ? 1 : 0;
        }
        //插入个人聊天消息表
        rerObject = tools.operationalDatabase(
          `REPLACE INTO ${tableName}(name,receiveId,sendId,type,value,time,messageId,isRead,isSuccessSend,isDownLoad,DownLoadId,duration,fontSize,replay,isByRead,isServiceAcc) VALUES ('${sendName}','${toId}','${myId}','${type}','${value}','${time}','${msgId}','${isRead}','${sendding}','${isDown}','${downId}','${duration}','${fontSize}','${replay}', '${readStatus}',${isServiceAcc})`
        );
      }
      if (rerObject.success) {
        //插入会话列表
        rerObject = tools.operationalDatabase(
          `REPLACE INTO ${this.sqlTable.sessionList}(userId,isGroup,time) VALUES ('${result}','${isGroup}','${time}');`
        );
      }
      console.log(rerObject, rerObject.success, '入库结果')
      this.isSaved = true;
      return rerObject;
    },
    //更新个人信息表
    UpDateUser(userId, head, isRead) {
      tools.operationalDatabase(
        `${tools.createString(
          this.sqlTable,
          "userInformation"
        )}(_id INTEGER PRIMARY KEY AUTOINCREMENT, id CHAR(60) UNIQUE, name NVARCHAR(18), gender CHAR(2), head CHAR(60) NOT NULL DEFAULT"",account CHAR(20),jobtitle NVARCHAR(20) NOT NULL DEFAULT "",department NVARCHAR(20) NOT NULL DEFAULT "",isAdmin CHAR(2),radioOf CHAR(2),groupOf CHAR(2),remark NVARCHAR(50) NOT NULL DEFAULT "",nickname NVARCHAR(50) NOT NULL DEFAULT "");`
      );
      let res = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.userInformation} WHERE id='${userId}'`,
        1
      );
      if (res.list.length > 0) {
        if (res.list[0].head != head) {
          this.getAndSaveUserSql(userId, res.list[0].head, isRead);
        }
      } else {
        this.getAndSaveUserSql(userId, head, isRead);
      }
    },
    //离线广播消息保存
    insertOffBroad(sendId, broadValue) {
      tools.createBroad(this.sqlTable);
      let req = tools.operationalDatabase(
        `INSERT OR IGNORE INTO ${this.sqlTable.broadcastList}(broadSendId,value,title,time,messageId,isRead,isSuccessSend,attachsize,attach,attachName,aType,fileMap,deptIds,broadSendName) VALUES ${broadValue};`
      );
      this.insertUser(sendId, 1);
      // 查询未读广播条数
      this.getSessionBroad();
    },
    //广播消息 判断表是否存在，不存在则创建表，然后插入数据，最后获取发送人信息
    insertBroad(
      sendId,
      value,
      title,
      time,
      messageId,
      isRead,
      isSuccessSend,
      attachsize,
      attach,
      attachName,
      aType,
      fileMap,
      deptIds,
      sendUserName
    ) {
      tools.createBroad(this.sqlTable);
      value = value.replace(/\'/gi, '"');
      let insert = tools.operationalDatabase(
        `INSERT OR IGNORE INTO ${this.sqlTable.broadcastList}(broadSendId,value,title,time,messageId,isRead,isSuccessSend,attachsize,attach,attachName,aType,fileMap,deptIds,broadSendName) VALUES ('${sendId}','${value}','${title}','${time}','${messageId}','${isRead}','${isSuccessSend}','${attachsize}','${attach}','${attachName}','${aType}','${fileMap}','${deptIds}','${sendUserName}');`
      );
      this.insertUser(sendId, 0);
    },
    //删除广播消息
    deleteBroad(messageId) {
      tools.operationalDatabase(
        `DELETE FROM ${this.sqlTable.broadcastList} WHERE messageId='${messageId}'`
      );
    },
    //搜索是否存在用户|用户头像是否发生变化|添加用户|下载头像
    insertUser(userId, index) {
      //0强制请求修改，1查询修改
      tools.operationalDatabase(
        `${tools.createString(
          this.sqlTable,
          "userInformation"
        )}(_id INTEGER PRIMARY KEY AUTOINCREMENT, id CHAR(60) UNIQUE, name NVARCHAR(18), gender CHAR(2), head CHAR(60) NOT NULL DEFAULT"",account CHAR(20),jobtitle NVARCHAR(20) NOT NULL DEFAULT "",department NVARCHAR(20) NOT NULL DEFAULT "",isAdmin CHAR(2),radioOf CHAR(2),groupOf CHAR(2),remark NVARCHAR(50) NOT NULL DEFAULT "",nickname NVARCHAR(50) NOT NULL DEFAULT "");`
      );
      let res = tools.operationalDatabase(
        `SELECT head FROM ${this.sqlTable.userInformation} WHERE id='${userId}'`,
        1
      );
      let head = "";
      if (res.list.length > 0) head = res.list[0].head;
      if (index == 0 || (index == 1 && res.list.length == 0))
        this.getAndSaveUserSql(userId, head);
    },
    //获取用户信息
    getUserInfo(id, success, error) {
      getUserInfo_axios({
        userid: id,
      })
        .then(success)
        .catch(error);
    },
    //获取用户信息并保存
    getAndSaveUserSql(id, head, isRead = 0) {
      this.getUserInfo(id, (res) => {
        console.log(res, "12643======");
        if (res.result == 200) {
          let info = res.data;
          let job = info.jobtitle == null ? "" : info.jobtitle;
          let department =
            info.departmentname == null ? "" : info.departmentname;
          let userHead = info.head == null ? "" : info.head;
          let ggds = tools.operationalDatabase(
            `REPLACE INTO ${this.sqlTable.userInformation
            }(id,name,gender,head,account,jobtitle,department,isAdmin,radioOf,groupOf,nickname) VALUES('${info.id
            }','${info.name}','${info.gender ? info.gender : "1"}','${info.head
            }','${info.account}','${info.jobtitle}','${info.departmentname}','${info.isAdmin
            }','${info.radioOf}','${info.groupOf}','${info.nickname}');`
          );
          if (this.toInfo.isGroup == "1") {
            if (isRead == 1) {
              if (head != userHead) {
                for (let i = 0; i < this.chatList.length; i++) {
                  for (let j = 0; j < this.chatList[i].length; j++) {
                    if (id == this.chatList[i][j].sendId) {
                      this.$set(this.chatList[i][j], "head", userHead);
                    }
                  }
                }
              }
            }
          }
          if (head != userHead) {
            if (userHead == "") {
              tools.operationalDatabase(
                `UPDATE ${this.sqlTable.userInformation} SET head="" WHERE id='${id}';`
              );
            } else {
              tools.operationalDatabase(
                `UPDATE ${this.sqlTable.userInformation} SET head='${userHead}' WHERE id='${id}'`
              );
              if (this.myInfo.id == id)
                this.$store.state.myInfo.head = userHead;
              for (let i in this.sessionList) {
                this.sessionList[i].id == id &&
                  this.$set(this.sessionList[i], "head", userHead);
              }
            }
          }
        }
      });
    },

    //获取消息未读条数
    getMessageNoRead(id, tableName) {
      let data = tools.operationalDatabase(
        `SELECT count(isRead) AS num FROM ${tableName}
          WHERE isRead='0'
          AND (receiveId='${id}' OR sendId = '${id}')
          AND type != 'revocation';`,
        1
      );
      let count = data.list[0].num;
      return count;
    },
    // 初始化会话列表
    init_session_list() {
      //zk16标识，session先从数据库取（包含的是上一次在线时的所有会话），再从离线消息取，两个合并获取到完整的sessionlist
      tools.createSession(this.sqlTable);
      let session1 = tools.operationalDatabase(
        `SELECT a.*, b.*
          FROM
            ${this.sqlTable.sessionList} a,
            ${this.sqlTable.userInformation} b
          WHERE
            a.isGroup = '0'
          AND a.userId = b.id
          ORDER BY
            a._id DESC
          LIMIT 80;`,
        1
      );
      console.log(session1, 12737);
      let session2 = tools.operationalDatabase(
        `SELECT a.*, c.*
          FROM
            ${this.sqlTable.sessionList} a,
            ${this.sqlTable.groupList} c
          WHERE
            a.isGroup='1'
            AND a.userId = c.id
          ORDER BY
            a._id DESC
            LIMIT 50;`,
        1
      );
      console.log(session2, 12751);
      let list1 = session1.list; // 好友列表
      let list2 = session2.list; // 群列表
      let res = list1.concat(list2); // 会话列zk128表示，res是session的来源

      res.sort((a, b) => {
        //按时间排序
        return b.time - a.time;
      });
      res.splice(100); //列表只展现100个
      list1 = res.filter((i) => {
        //好友列表
        return i.id.length < 10;
      });

      //获取会话列表好友状态(新)
      let newArr = [];
      for (let i in list1) {
        newArr.push(list1[i].id);
      }
      let arr = newArr.join(",");
      // 批量获取会话列表的在线状态
      getUsersStatus({ ids: arr }).then((data) => {
        if (data.result == "200") {
          for (let i in list1) {
            for (let i in data.data) {
              if (list1[i].id == data.data[i].id) {
                list1[i]["status"] = data.data[i].status;
              }
            }
          }
        }
      });
      for (let i in res) {
        let id = res[i].userId;
        let tableName =
          res[i].isGroup == "1"
            ? this.sqlTable.messageList
            : this.sqlTable.privateList;
        let data = tools.operationalDatabase(
          `SELECT * FROM ${tableName} WHERE receiveId='${id}' OR sendId='${id}' ORDER BY time DESC limit 1;`,
          1
        );
        let count = this.getMessageNoRead(id, tableName); //获取消息未读条数，zk128标识，未读数目从此处获取
        let value = {
          value: "",
          noRead: count,
        };
        if (data.list[0]) value = Object.assign(value, data.list[0]);
        Object.assign(res[i], value);
        let groupInfo = tools.operationalDatabase(
          `SELECT * FROM ${res[i].isGroup == "0"
            ? this.sqlTable.userInformation
            : this.sqlTable.groupList
          } WHERE id='${res[i].id}';`,
          1
        );
        if (groupInfo.list.length > 0) {
          res[i].name = groupInfo.list[0].name;
        }
      }
      if (this.isShare) {
        // 过滤掉常用联系人modalCheckArray.list(不包含群)/最近联系人modalCheckArray.list2(包含群)/我的群组已存在群里的部分modalCheckArray.list4(群)
        res = res.filter(
          (item) => this.shareChoosed.indexOf(item.ID || item.id) == -1
        );
      }
      return res;
    },
    //获取会话列表，zk标记
    getSessionList() {
      //this.getSessionBroad();
      let list = this.getSystemList(); // []
      this.sessionList = this.init_session_list(); //  []

      console.log(this.sessionList, list, "数据库的会话列表");
      let arr = [];
      for (let i in this.sessionList) {
        if (
          !this.sessionList[i].broadSendId &&
          // (!this.sessionList[i].name || this.sessionList[i].name == "")
          this.$isNull(this.sessionList[i].name) //zk16修改判断为空
        ) {
          //zk16标识，坏数据删除
          let isGroup = this.sessionList[i].isGroup == 0 ? false : true;
          tools.operationalDatabase(
            `DELETE FROM ${this.sqlTable.sessionList} WHERE userId='${this.sessionList[i].id}'`
          );
          if (isGroup) {
            tools.operationalDatabase(
              `DELETE FROM ${this.sqlTable.messageList} WHERE receiveId='${this.sessionList[i].id}'`
            );
          } else {
            tools.operationalDatabase(
              `DELETE FROM ${this.sqlTable.privateList} WHERE receiveId='${this.sessionList[i].id}' OR sendId='${this.sessionList[i].id}';`
            );
          }
          this.sessionList.splice(i, 1); //zk16注释
        }
        if (this.sessionList[i].type == "text")
          this.$set(
            this.sessionList[i],
            "value",
            this.toExpression(this.sessionList[i].value)
          );

        console.log(this.offline_arr, 10772);
        if (this.offline_arr.length > 0) {
          for (let j = 0, lens = this.offline_arr.length; j < lens; j++) {
            let a = this.offline_arr[j];
            let b;
            if (a.type != "3") {
              b = JSON.parse(a.lastMsg.value);
            } else {
              b = a.lastMsg.value;
            }
            if (
              this.sessionList[i].userId == this.offline_arr[j].sendUserId &&
              this.sessionList[i].time < this.offline_arr[j].time
            ) {
              this.$set(this.sessionList[i], "time", a.time);
              this.$set(
                this.sessionList[i],
                "value",
                a.type == "GPS"
                  ? "[位置]"
                  : a.type == "file"
                    ? "[文件]"
                    : a.type == "audio"
                      ? "[语音]"
                      : a.type == "image"
                        ? "[图片]"
                        : a.type == "video"
                          ? "[视频]"
                          : a.type == "shareGroup"
                            ? "[群分享]"
                            : a.value
              );
            } else if (j == lens - 1) {
              arr.push({
                userId: a.sendUserId,
                value:
                  a.type == "GPS"
                    ? "[位置]"
                    : a.type == "file"
                      ? "[文件]"
                      : a.type == "audio"
                        ? "[语音]"
                        : a.type == "image"
                          ? "[图片]"
                          : a.type == "video"
                            ? "[视频]"
                            : a.type == "shareGroup"
                              ? "[群分享]"
                              : a.value,
                time: a.time,
                name: a.type == "2" ? b.receiveName : b.sendName,
              });
            }
          }
        }
      }
      console.log(arr, 10778)
      if (arr.length > 0) this.sessionList = this.sessionList.concat(arr);
      this.sessionList = this.sessionList.concat(list);

      console.log(this.sessionList, "最后的会话列表(包含离线消息)");
      this.sortSessionList();
      // 获取消息列表是否有未读的消息,有则提示闪烁
      for (let y = 0; y < this.sessionList.length; y++) {
        if (this.sessionList[y].noRead == 1) {
          console.log(this.sessionList[y], "有未读消息");
          this.messageTips(
            this.sessionList[y].id,
            this.sessionList[y].type,
            this.sessionList[y].value,
            this.sessionList[y].headPath,
            this.sessionList[y].name,
            0
          );
        }
        break;
      }
    },
    //点击聊天时修改未读=>已读
    updateIsRead(id, isGroup) {
      let tableName =
        isGroup == "1" ? this.sqlTable.messageList : this.sqlTable.privateList;
      let rep = tools.operationalDatabase(
        `UPDATE ${tableName} SET isRead='1' WHERE (${isGroup == "1"
          ? `receiveId='${id}') AND isRead <> '1'` //优化切换聊天对象卡顿问题 0205
          : `receiveId='${id}' OR sendId='${id}') AND isRead <> '1'`
        };`
      );
    },
    //更新群详情
    getGroupAndUsers(id) {
      getGroupAndUsersById({
        groupid: id,
      })
        .then((msg) => {
          msg = msg.data;
          console.log(msg, "获取群成员之后的返回值");
          if (msg) {
            this.group_detail = msg;
            for (let i = 0; i < this.group_detail.users.length; i++) {
              let a = this.group_detail.users[i];
              if (a.ID == this.myInfo.id) {
                this.my_position = a.POSITION;
                break;
              }
            }
            this.$nextTick(() => {
              this.saveGroupInfo(msg); // 保存群详情
              // 新增下载头像
              let users = [];
              if (msg.users.length > 50) {
                users = msg.users.slice(0, 50);
              } else {
                users = msg.users;
              }
              users.map((item) => {
                this.downLoadHeadPath(item);
              });
            });
            // 对群成员进行排序
            this.$groupSort();
            this.$forceUpdate();
          }
        })
        .catch((error) => {
          this.group_detail = {
            users: [],
          };
        });
    },
    //点击聊天时获取聊天记录
    getMessageRecord(isNoRead) {
      this.my_position = 3;
      let id = this.toInfo.id;
      let isTrue = this.toInfo.isGroup == "1";
      // 将群聊天记录或者个人聊天记录与用户信息表做结合当聊天记录中的发送id与用户信息中的id相同时
      let str = `${isTrue ? this.sqlTable.messageList : this.sqlTable.privateList
        } a left join ${this.sqlTable.userInformation} b on a.sendId=b.id WHERE ${isTrue
          ? `a.receiveId='${id}'`
          : `a.sendId='${id}' OR a.receiveId='${id}'`
        }`;
      // 以时间从旧到新的顺序从聊天记录汇总出聊天的所有记录，个人信息的头像，和个人信息的性别
      let res = tools.operationalDatabase(
        `SELECT a.*,b.head,b.gender FROM ${str} ORDER BY time DESC LIMIT '${this.chatMsgPage}', '${this.chatMsgPageSize}';`,
        1
      );
      console.log(res, 'getMessageRecord 回调');
      let total = tools.operationalDatabase(
        `SELECT count(1) total FROM ${isTrue ? this.sqlTable.messageList : this.sqlTable.privateList
        } WHERE sendId='${id}' OR receiveId='${id}';`,
        1
      );
      this.chatMsgTotal = total.list[0].total;
      console.log("聊天总量", this.chatMsgTotal);
      let len = res.list.length;
      // 如果该对象本地库数据内存在未读消息:
      if (len) {
        let newArr = res.list.filter((m) => {
          return m.isByRead != 1 && m.sendId == this.toInfo.id;
        });
        if (newArr.length) {
          let userId = newArr[0].receiveId;
          let key = newArr[0].messageId;
          // this.ws.send(this.$publicSend(key,'1.500','1.1.1015',{ userId }));//zk注释
        }
      }
      // 查询出当前群聊所有的未读消息
      let str1 = `${isTrue ? this.sqlTable.messageList : this.sqlTable.privateList
        } a left join ${this.sqlTable.userInformation} b on a.sendId=b.id WHERE ${isTrue
          ? `a.receiveId='${id}'`
          : `(a.sendId='${id}' OR a.receiveId='${id}')`
        } AND isRead='0'`;
      let result = tools.operationalDatabase(
        `SELECT a.*,b.head,b.gender FROM ${str1};`,
        1
      );
      console.log("查询所有未读", result);
      // 如果未读记录多余屏幕显示则记录第一条聊天记录id
      if (result.list.length > 20) {
        //记录首条未读消息id
        this.firstUnreadId = result.list[0].messageId;
      } else {
        this.firstUnreadId = "";
      }
      //查询出当前群聊所有的未读消息并向后台发送已读请求
      for (let i = 0, len = result.list.length; i < len; i++) {
        // 处理群的已读未读
        if (
          result.list[i].sendId != this.myInfo.id &&
          result.list[i].isRead != "1" &&
          isTrue
        ) {
          console.log(result.list[i].messageId, 10326);
          this.ws.send(
            this.$publicSend(result.list[i].messageId, "1.500", "1.1.2005", {
              sendUserId: result.list[i].sendId,
              receiveUserId: this.myInfo.id,
              groupId: this.toInfo.id,
            })
          );
        }else if(
          result.list[i].sendId != this.myInfo.id &&
          result.list[i].isRead != "1" &&
          !isTrue
        ) {
          this.$publicSend(result.list[i].messageId, "1.500", "1.1.1014", {
            sendUserId: this.toInfo.id,
            receiveUserId: this.myInfo.id,
            timestamp: new Date().getTime(),
            isServiceAcc: this.myInfo.authCustservice,
          })
        }
      }

      console.log(res, "1298000==============");
      // 处理历史消息,发送已读未读
      for (let i = 0, len = res.list.length; i < len; i++) {
        // 处理群的已读未读
        res.list[i].value = this.setHistoryMsg(res.list[i]);
        // if (
        //   res.list[i].sendId != this.myInfo.id &&
        //   res.list[i].isRead != "1" &&
        //   isTrue
        // ) {
        //   this.ws.send(
        //     this.$publicSend(res.list[i].messageId, "1.500", "1.1.2005", {
        //       sendUserId: res.list[i].sendId,
        //       receiveUserId: this.myInfo.id,
        //       groupId: this.toInfo.id,
        //     })
        //   );
        // }//已读请求上移到对全体未读执行
        // 更新下载列表状态
        if (this.downloadList.length > 0) {
          for (let j = 0; j < this.downloadList.length; j++) {
            if (res.list[i].messageId == this.downloadList[j].messageId) {
              res.list[i] = this.downloadList[j];
            }
          }
        }
        // 更新上传列表状态
        if (this.updateFileList.length > 0) {
          for (let k = 0; k < this.updateFileList.length; k++) {
            if (res.list[i].messageId == this.updateFileList[k].messageId) {
              res.list[i] = this.updateFileList[k];
            }
          }
        }
      }
      this.chatList[1] = this.chatList[1].concat(res.list);
      console.log(this.chatList[1], "init历史数据");
      let _this = this;
      this.firstFrame = this.chatList[1]; //zk14新增，解决无限循环问题
      this.chatList[1].forEach((val) => {
        if (val.type == "image" && !val.value) {
          this.$downLoad(
            "api/v1/oim/image/downloadsmall.do",
            val.DownLoadId,
            (wt) => {
              var fileReader = new FileReader();
              fileReader.onload = function (w) {
                let info = '{"return_msg":""}';
                if (wt.size !== 0) {
                  let base64 = w.target.result.replace(
                    /^data\:.{1,40}base64\,/gi,
                    ""
                  );
                  let arr = val.value
                    ? val.value.split(".").splice(-1)[0]
                    : "png"; //获取后缀
                  info = _this.$shell("SaveFileStreamczs", [
                    _this.myInfo.id,
                    val.DownLoadId,
                    arr,
                    base64,
                    0,
                  ]);
                }

                info = JSON.parse(info);
                //这里smallvalue是大图地址，value是小图地址，将错就错吧
                console.log("info111", info);
                //value写入数据库
                let tableName =
                  _this.toInfo.isGroup == "1"
                    ? _this.sqlTable.messageList
                    : _this.sqlTable.privateList;
                let ss = tools.operationalDatabase(
                  `UPDATE ${tableName} SET value='${info.return_msg}' WHERE messageId='${val.messageId}';`
                );

                // _this.currentTempChat[0].forEach((vals,index) => {
                //   if(vals.messageId == val.messageId){
                //     this.currentTempChat[0][index].value = info.return_msg
                //   }
                // })
                // _this.currentTempChat[1].forEach((vals,index) => {
                //   if(vals.messageId == val.messageId){
                //     this.currentTempChat[0][index].value = info.return_msg
                //   }
                // })
                _this.currentTempChat.forEach((v, i) => {
                  _this.currentTempChat[i].forEach((vals, index) => {
                    if (vals.messageId == val.messageId) {
                      _this.currentTempChat[i][index].value = info.return_msg;
                    }
                  });
                });
              };
              fileReader.readAsDataURL(wt);
            },
            (wt) => {
              console.warn("error", wt);
            }
          );
        }
      });
      
      // console.trace('保存既有消息的时间戳 调用栈')

      //2024.5.23 cq新增，根据既有消息的时间戳对消息重排，防止消息顺序混乱
      const timeList = this.chatList[0].concat(this.chatList[1]).map(item=>{
        item.time = currentTempChatTimeMap[item.messageId] || item.time
        return item
      }).sort((a,b)=>{
        return b.time - a.time
      })
      
      //1214zk新增，获取离线消息时同时修改currentTempChat
      //2024.5.23 cq修改，获取离线消息时同时修改currentTempChat
      let count = 0;
      this.currentTempChat = [[], []];
      for (let i in timeList) {
        const item = timeList[i]
        if (count < this.readNumber) {
          this.currentTempChat[0].unshift(item);
        } else if (count < this.readNumber * 2) {
          this.currentTempChat[1].push(item);
        }
        count++;
      }

      this.$forceUpdate();
      let userList = [];
      console.log(this.toInfo, this.chatList, 13188);
      if (this.toInfo.isGroup == "1") {
        getGroupAndUsersById({
          groupid: id,
        }).then((res) => {
          console.log(res, 10864);
          if (res.result == 200) {
            userList = res.data.users || [];
            this.group_detail = res.data || {};
            for (let j = 0; j < userList.length; j++) {
              if (userList[j].ID == this.myInfo.id) {
                this.my_position = userList[j].POSITION;
                break;
              }
            }
            console.log("群====未读改已读");
            this.$nextTick(() => {
              this.saveGroupInfo(res.data);
            });
          } else if (res.result == 2) {
            this.isDissolve = true;
          }
        });
      } else {
        console.log("未读改已读", this.$store.state.user_configure[0].notify);
        if (
          isNoRead > 0 ||
          this.$store.state.user_configure[0].notify === "false"
        ) {
          // 改为有未读消息、设置关闭消息通知时再发送已读未读socket
          // let key =
          //     (this.chatList[1] &&
          //       this.chatList[1][0] &&
          //       this.chatList[1][0].messageId) ||
          //     this.$func.uuid();
          // this.ws.send(
          //   this.$publicSend(key, "1.500", "1.1.1014", {
          //     sendUserId: this.toInfo.id,
          //     receiveUserId: this.myInfo.id,
          //     timestamp: new Date().getTime(),
          //     isServiceAcc: this.myInfo.authCustservice
          //   })
          // );
          // 2022/5/27 zc修改 每次将私聊中所有未读改已读的都发送socket
          this.chatList[1].forEach((val) => {
            if (val.isRead == 0) {
              let key = (val && val.messageId) || this.$func.uuid();
              console.log("发送已读socket");
              this.ws.send(
                this.$publicSend(key, "1.500", "1.1.1014", {
                  sendUserId: this.toInfo.id,
                  receiveUserId: this.myInfo.id,
                  timestamp: new Date().getTime(),
                  isServiceAcc: this.myInfo.authCustservice,
                })
              );
            }
          });
        }
      }
      this.$nextTick(() => {
        this.updateIsRead(this.toInfo.id, this.toInfo.isGroup); // 更改数据库未读状态
      });
      // 新增下载头像//zk标注，切换聊天时此处循环下载头像
      this.chatList[1].map((item) => {
        this.downLoadHeadPath(item);
      });
    },
    resetContacts() {
      for (let i in this.friendsGroup) {
        for (let k = 0; k < this.friendsGroup[i].length; k++) {
          if (this.friendsGroup[i][k].isChoose) {
            this.friendsGroup[i][k].isChoose = false;
          }
        }
      }
    },
    //初始化转发等选择
    resetModalFirst() {
      this.checkPersonArray = [];
      this.participant = [];
      this.modalCheckArray = {
        show: false,
      };
      this.$refs.modlaFirst.modalSearchValue = "";
      this.$refs.modlaFirst.modalNameValue = "";
      // this.modalSearchValue = this.modalNameValue = "";
      this.$refs.modlaFirst.modalSearchResult = [];
      console.log("==>", this.modalCheckArray.list3);
      if (this.modalCheckArray.list3) {
        this.modalCheckArray.list3.forEach((item) => {
          this.$set(item, "isChoose", false);
        });
      }
      for (let i = 0; i < this.modalFirstList[2].structureList.length; i++) {
        this.$set(this.modalFirstList[2].structureList[i], "isChoose", false);
      }
      for (let i = 0; i < this.friendsGroup.length; i++) {
        for (let j = 0; j < this.friendsGroup[i].USER.length; j++) {
          this.$set(this.friendsGroup[i].USER[j], "isChoose", false);
        }
      }
      if (this.groupList.length > 0) {
        for (let i = 0; i < this.groupList.length; i++) {
          this.$set(this.groupList[i], "isChoose", false);
        }
      }
      // this.resetContacts();
    },

    // async getAllPerson(personArr){// zk0531新增,组织建构勾选去重,并获取部门里的成员,返回值为全部成员的数组,personArr:原始数组,里面有人,有部门
    //   let arr = [...personArr]
    //   let tempArr = []
    //   for(let i in arr){
    //     if(arr[i].FID){//部门
    //       let id = arr[i].id || arr[i].FID
    //       let res = await this.$axios.post(`${this.$store.state.url}user/getGroup.do`,{fid:id})
    //       if(res.data.result == 200){//获取数据不为空
    //         res.data.data.forEach(item=>{//数据格式调整,防止回显错误
    //           let idx = item.id || item.ID || item.FID
    //           item.id = idx
    //           let name = item.name || item.NAME || item.LEABLE
    //           item.name = name
    //         })
    //         let temp = await this.getAllPerson(res.data.data)
    //         tempArr = tempArr.concat(temp)//不做数组的拼接,做去重拼接
    //       }
    //       if(i==arr.length-1){//递归出口,当前已经是数组的最后一项
    //         return tempArr;
    //       }
    //     }else{//人
    //       tempArr.push(arr[i])
    //       if(i==arr.length-1){//递归出口,当前已经是数组的最后一项
    //         return tempArr;
    //       }
    //     }
    //   }
    //   return tempArr;
    // },
    async getAllPerson(personArr) {
      // zk0531新增,组织建构勾选去重,并获取部门里的成员,返回值为全部成员的数组,personArr:原始数组,里面有人,有部门
      this.$startLoading(".ivu-modal-content-drag");
      let arr = [...personArr];
      let tempArr = [];
      for (let i in arr) {
        if (arr[i].FID) {
          //部门
          let id = arr[i].id || arr[i].FID;
          let res = await this.$axios.post(
            `${this.$store.state.url}user/getUsersByDeptId.do`,
            { deptId: id }
          );
          if (res.data.result == 200) {
            //获取数据不为空
            tempArr = tempArr.concat(res.data.data);
          }
        } else {
          //人
          tempArr.push(arr[i]);
        }
      }
      this.$endLoading();
      return tempArr;
    },

    //选择聊天
    toChat(info) {
      console.log(info, 10643);
      this.havePre = true; //zk新增，可以上翻
      this.havenext = false; //zk新增，不可以下翻
      console.log(info, this.toInfo, "切换聊天");
      if (this.isOndropHandle) {
        this.$Message.warning("文件处理中,请稍后");
        return;
      }
      this.$store.commit("Is_Update_SessionList", info); //新增强制刷新会话列表未读消息数量
      if (info.isGroup == 0) {
        this.$store.commit("Sync_User_Status", info.status); //新增强制刷新用户的状态
        this.updateSessionListStatus(info.id);
      }
      //this.updateSessionListStatus(info.id);
      this.flagHeadType = 0;
      this.chatMsgPage = 0;
      this.toInfoHeadPath = "";
      if (!this.$isNull(info.headPath)) this.toInfoHeadPath = info.headPath;
      // this.chating=true;//点击聊天到会话显示聊天界面//zk注释
      this.setChating(true);
      this.setb4Leave(true);
      this.$refs.deleteGroupMembers.memberSelList = [];
      // this.memberSelList = []; //删除群成员窗口 舒适化
      this.$refs.deleteGroupMembers.searchMember = "";
      // this.searchMember = ""; //删除群成员窗口 舒适化
      this.delMemberView = false; //删除群成员窗口 舒适化
      this.isMultiSelect = false; //多选功能初始化
      this.specified_show = false; //切换隐藏群@弹框
      this.quotationsShow = false; //隐藏重点语录
      this.editPositionShow = false;
      this.addProcessedShow = false;
      this.newCalendarShow = false; //新建日程
      this.editFlag = true; //zk新增，编辑框隐藏之后，编辑按钮可用
      this.noticeConfirm = false; //关闭广告删除
      if (this.toInfo.id != info.id || this.toInfo.systemId != info.systemId) {
        this.delMemberView = false;
        this.group_info_show = false;
        this.files_show = false;
        this.reconnect = false; //是否重连
        this.editActive = true;
        this.toinfoSession = info || {};
        this.upLoadIng = false;
        if (info.noRead && info.noRead != 0 && this.messageTipsArr) {
          //let res = this.$shell("GetInfoUserId", [info.systemId || info.id]);
          if (info.id in this.messageTipsArr) {
            delete this.messageTipsArr[info.id];
            this.showTips();
          }
          console.log("闪烁，点击聊天进入了");
        }
        this.viewTarget = info;
        this.toInfo = info;
        // console.warn(this.toInfo);
        //点击会话列表获取置顶状态
        if (this.toInfo) this.topChat = this.get_top_boolean(this.toInfo.id);
        // this.$set(info, 'noRead', 0);
        // this.$set(info, 'isRead', 1);
        // this.$set(info, 'isAite', false);
        //系统消息选定
        if (info.systemId) {
          this.$set(info, "noRead", 0);
          this.$set(info, "isRead", 1);
          this.$set(info, "isAite", false);
          this.delMemberView = false;
          this.systemShow = true;
          // this.chating = false;//zk注释
          this.setChating(false);
          this.setb4Leave(false);
          this.groupNews = [];
          this.auditNotice = [];
          let res = tools.operationalDatabase(
            `SELECT * FROM ${this.sqlTable.group_message} ORDER BY time DESC;`,
            1
          );
          let notice = tools.operationalDatabase(
            `SELECT * FROM ${this.sqlTable.audit_notice} ORDER BY time DESC;`,
            1
          );
          this.auditNotice = notice.list || [];
          this.groupNews = res.list || [];
          this.setSessionListCheck(info.systemId, true);
          tools.operationalDatabase(
            `UPDATE ${this.sqlTable.group_message} SET isRead='1' WHERE isRead='0';`
          );
          tools.operationalDatabase(
            `UPDATE ${this.sqlTable.audit_notice} SET isRead='1' WHERE isRead='0';`
          );
        } else {
          this.systemShow = false;
          this.contentReset = new Date().getTime();
          this.activeRecords = false;
          this.personal_chat_list = false;
          this.broad_show_item = null;
          this.broadShow = false;
          let res = tools.operationalDatabase(
            `SELECT * FROM ${info.isGroup == "0"
              ? this.sqlTable.userInformation
              : this.sqlTable.groupList
            } WHERE id='${info.id}';`,
            1
          );

          if (res.list.length > 0) {
            res.list[0].isGroup = info.isGroup;
            res.list[0].GROUPID = info.GROUPID;
            // this.toInfo = res.list[0];
          }
          this.chatList = [[], []];
          // this.chating = true;//zk注释
          this.setChating(true);
          this.setb4Leave(true);
          let toinfo = this.toInfo;
          if (this.toInfo.isGroup == "1") {
            this.isDissolve = true;
            let id = info.id;
            this.groupList.forEach((item) => {
              if (item.id == id) {
                this.isDissolve = false;
              }
            });
          } else {
            this.isDissolve = false;
            this.isLinkman();
            // 新增判断数据库是否存在该用户信息id、departmentnames，若没有调用查询接口
            let userIdList = tools.operationalDatabase(
              `SELECT * FROM ${this.sqlTable.userInformation} WHERE id = ${this.toInfo.id};`,
              1
            );
            let flagU = false;
            if (userIdList.list.length == 0) {
              flagU = true;
            } else {
              if (this.$isNull(userIdList.list[0].departmentnames))
                flagU = true;
            }
            console.log(userIdList, "userIdListuserIdListuserIdList");
            if (flagU) {
              this.getUserInfo(
                this.toInfo.id,
                (data) => {
                  if (data.result == 200) {
                    if (toinfo.id == this.toInfo.id) {
                      this.$set(this.toInfo, "head", data.data.head || "");
                      //新增部门显示(新建联系人第一次无法加载部门信息)
                      this.$set(
                        this.toInfo,
                        "departmentnames",
                        data.data.departmentnames || ""
                      );
                      this.$set(
                        this.toInfo,
                        "jobtitle",
                        data.data.jobtitle || ""
                      );
                      info.head = data.data.head || "";
                      let userInfo = data.data || {};
                      let req = tools.operationalDatabase(
                        `REPLACE INTO ${this.sqlTable.userInformation
                        }(id,name,gender,head,account,jobtitle,department,isAdmin,radioOf,groupOf,nickname,departmentnames) VALUES('${userInfo.id
                        }','${userInfo.name}','${userInfo.gender ? userInfo.gender : "1"
                        }','${userInfo.head}','${userInfo.account}','${userInfo.jobtitle
                        }','${userInfo.departmentname}','${userInfo.isAdmin
                        }','${userInfo.radioOf}','${userInfo.groupOf}','${userInfo.nickname
                        }','${userInfo.departmentnames}');`
                      );
                    }
                  }
                },
                (err) => { }
              );
            }
          }
          if (info.offline) {
            // 发送socket获取离线消息
            this.getMessageRecord();
            console.log("开始拉取离线");
            this.getOffline(
              this.toInfo.id,
              this.toInfo.isGroup ? "2" : "1",
              1,
              "0"
            );
            // 放到拉取离线时修改状态
            // info.offline = false;
          } else {
            this.getMessageRecord(info.noRead); // 添加有未读消息时的标识info.noRead
          }
          this.$set(info, "noRead", 0);
          this.$set(info, "isRead", 1);
          this.$set(info, "isAite", false);
          this.setSessionListCheck(info.id, false);
          this.messageFree = this.free_icon_sign(this.toInfo.id); //免打扰
          this.$forceUpdate();
          let initid = this.$func.uuid();
        }
      } else if (this.toInfo.id == info.systemId) {
        this.setSessionListCheck(info.systemId, true);
      } else if (
        this.toInfo.systemId == info.systemId &&
        this.toInfo.systemId != undefined
      ) {
        //zk1211新增，点击聊天时systemid相等切不为undefined
        this.setChating(false);
        this.setb4Leave(false);
      }
      // 切换联系人自动设置光标
      this.$refs.newsEditor.setgunagbiao();
      if (this.toInfo.isGroup == 0) this.downLoadHeadPath(this.toInfo); //新增下载头像

      this.readUsers = null;
      this.unreadUsers = null;

      let count = 0;
      this.currentTempChat = [[], []];
      for (let i in this.chatList) {
        for (let j in this.chatList[i]) {
          if (count < this.readNumber) {
            this.currentTempChat[0].unshift(this.chatList[i][j]);
          } else if (count < this.readNumber * 2) {
            this.currentTempChat[1].push(this.chatList[i][j]);
          }
          count++;
        }
      }
    },

    cancelDown() {
      for (let item of this.fileList) {
        item.ifChoose = false;
      }
      this.fileList = [];
    },

    inputClick() {
      if (!this.siderArray[2].active && !this.siderArray[3].active) {
        if (!this.isSearchShow) {
          this.$changeTitleColor("#fff", "#f7f7f7");
        }
      }
      this.broad_show_item = null;
      this.myCardShow = false;
      this.viewTarget = null;
      this.viewTargetShow = false;
      this.group_info_show = false;
      this.files_show = false;
      this.deleteIcon = false;
      this.read_info_show = false;
      this.config_active = false; //左下角设置
      this.quickShow = false;
      this.state_show = false; //工作状态隐藏
      this.faceShow = false; //表情隐藏
      this.specified_show = false; //@隐藏
      this.editPositionShow = false;
      this.control_show = false;
      this.$refs.isMycollection.collectionItem = null;
      this.addProcessedShow = false; //添加待办隐藏
      this.addNoticeShow = false;
      this.groupNoticeShow = false;
      this.friendsEditShow = false;
      this.newCalendarShow = false; //新建日程
      this.editFlag = true; //zk新增，编辑框隐藏之后，编辑按钮可用
      this.chatFunctionActive = false;
      this.copyShow = false; //粘贴
      this.timeOpen = false;
      this.$forceUpdate();
    },
    //点击任何位置隐藏列表
    hiddenAll(e) {
      this.$store.commit("setsearchValue", "");
      console.log(this.isDepartmentShow, "isDepartmentShowisDepartmentShow");
      this.isDepartmentShow = false; //隐藏部门选择弹框
      this.faceShow = false; //表情隐藏
      this.quickShow = false; //快捷回复隐藏
      this.broad_show_item = null;
      this.myCardShow = false;
      this.viewTarget = null;
      this.viewTargetShow = false;
      this.searchTargetShow = false;
      this.group_info_show = false;
      this.files_show = false;
      this.deleteIcon = false;
      this.searchResultShow = false;
      this.search_broad_show_item = false;
      this.read_info_show = false;
      this.config_active = false; //左下角设置
      this.state_show = false; //工作状态隐藏
      this.specified_show = false; //@隐藏
      this.editPositionShow = false;
      this.control_show = false;
      this.$refs.isMycollection.collectionItem = null;
      this.addProcessedShow = false; //添加待办隐藏
      this.addNoticeShow = false;
      this.groupNoticeShow = false;
      this.friendsEditShow = false;
      this.newCalendarShow = false; //新建日程
      this.editFlag = true; //zk新增，编辑框隐藏之后，编辑按钮可用
      this.chatFunctionActive = false;
      this.copyShow = false; //粘贴
      this.timeOpen = false;
      this.detailShow = false; //综合搜索详情
      this.isListSider = true; //侧边栏
      this.status = this.toInfo.status;
      this.$forceUpdate();
    },
    //添加工作状态
    toSetStatus() {
      this.myCardShow = false;
      this.state_show = !this.state_show;
    },
    setClearClose() {
      this.clearStatus = false;
    },
    //关闭设置页
    setClose(info) {
      var arr = [
        "",
        "deleteShow",
        "windowStatus",
        "passwordStatus",
        "clearStatus",
        "broadSendShow",
      ];
      if (info != 0) this.$data[arr[info]] = false;
    },

    //我的个人资料card
    toMyInfo(e) {
      this.state_show = false;
      this.myCardShow = !this.myCardShow;
      this.myMobile = this.myInfo.mobile;
      this.myEmail = this.myInfo.email;
      this.myTelephone = this.myInfo.telephone;
    },
    showService() {
      //点击客服图标

      this.isShowService = true;
    },

    setModalFirst(index) {
      this.modalFirst = true;
      if (this.modalTitle != index) {
        this.resetModalFirst();
      }
      this.modalTitle = index;
      if (index == 1) {
        if (this.broadSendList.length > 0) {
          if (this.checkPersonArray.length <= 0) {
            for (let i in this.broadSendList) {
              this.checkPersonArray.push(this.broadSendList[i]);
            }
          }
        }
      }
    },
    // 新增获取组织架构 and 常用联系人
    getTreeAndUserCategory() {
      // console.log(this.checkPersonArray,"显隐是否能触发函数")//zk0601标注,组织架构弹框显示,isChoose,setLastChoose
      // 过滤掉常用联系人modalCheckArray.list(不包含群)/最近联系人modalCheckArray.list2(包含群)/我的群组已存在群里的部分modalCheckArray.list4(群)
      // console.log(this.modalCheckArray)
      // zk0601新增,组织架构折叠状态的勾选的初始化
      let checkIdList = [];
      for (let i in this.checkPersonArray) {
        let id = this.checkPersonArray[i].id || this.checkPersonArray[i].ID;
        checkIdList.push(id);
      }
      let index = this.modalCheckArray.index;
      if (this.modalCheckArray.list) {
        //常用联系人
        for (let i in this.modalCheckArray.list) {
          for (let j in this.modalCheckArray.list[i].USER) {
            let myid =
              this.modalCheckArray.list[i].USER[j].id ||
              this.modalCheckArray.list[i].USER[j].ID;
            if (checkIdList.indexOf(myid) != -1) {
              //是被勾选的
              this.$set(this.modalCheckArray.list[i].USER[j], "isChoose", true);
              continue;
            } else {
              this.$set(
                this.modalCheckArray.list[i].USER[j],
                "isChoose",
                false
              );
            }
          }
        }
      }
      if (this.modalCheckArray.list2) {
        //组织架构
        let count = 0;
        for (let i in this.modalCheckArray.list2[index]) {
          let myid =
            this.modalCheckArray.list2[index][i].id ||
            this.modalCheckArray.list2[index][i].ID;
          if (checkIdList.indexOf(myid) != -1) {
            //是被勾选的
            this.$set(this.modalCheckArray.list2[index][i], "isChoose", true);
            count++;
            continue;
          } else {
            this.$set(this.modalCheckArray.list2[index][i], "isChoose", false);
          }
        }
        if (count == this.modalCheckArray.list2[index].length) {
          this.$refs.modlaFirst.organizationChoose = true;
        } else {
          this.$refs.modlaFirst.organizationChoose = false;
        }
      }

      if (this.onlyFirst) {
        this.onlyFirst = false;
        this.getUserCategoryNames();
        this.getTreeList();
      }
    },

    searchToView(e, item) {
      this.getCurCoor(e);
      this.searchviewTarget = item;
      this.detailShow = true;
      this.searchTargetShow = true;
      this.search_broad_show_item = false;
      this.recordshow = false;
      this.viewTarget = item;
      this.isLinkman(item.id);
    },
    //获取坐标
    getCurCoor(e) {
      let rect = e.target.getBoundingClientRect();
      let maxTop = document.body.clientHeight;
      // this.toInfoTop = maxTop - rect.top - 400 > 0 ? rect.top-10 : maxTop - 400-90;
      this.toInfoTop = 42; //修改后dx
      this.toInfoLeft = rect.left - 360 > 0 ? rect.left - 280 : 56;
    },

    setBookListShow(index, id) {
      console.log(index, "index=>");
      if (index != 2) {
        this.currentStructureName = this.currentStructureList = [];
        this.currentStructureIndex = 0;
      }
      if (index == 0) {
        //初始化常用联系人
        this.getTreeAndUserCategory();
      }
      if (index == 2) {
        //初始化组织架构
        this.getTreeList(id);
      }
      if (index == 3) {
        //新接口0,初始化，1查询部门人员
        this.flagHeadType = 3;
        this.searchDepartment(0);
      }
      for (let i in this.bookList) {
        this.bookList[i].show = false;
        if (i == index) this.bookList[i].show = true;
      }
      this.$forceUpdate();
    },
    //新增添加的查询我的部门接口方法
    searchDepartment(flag) {
      let _this = this;
      getMyDepartments({
        deptid: this.myInfo.depId,
        isOrg: flag,
      }).then((msg) => {
        //我的部门
        msg = msg.data || [];
        function insertDepartmentItem(item, i) {
          return getMyDepartments({
            deptid: item.FID,
            isOrg: 1,
          }).then((res) => {
            //我的部门
            res = res.data || [];
            item.ARR = res || [];
            item.open = true;
          });
        }
        async function insertDepartmen() {
          for (let i = 0; i < msg.length; i++) {
            await insertDepartmentItem(msg[i]);
          }
          _this.bookList[3].myDepartment = msg;
          _this.$forceUpdate();
          // 新增头像下载
          for (let temp of _this.bookList[3].myDepartment) {
            for (let item of temp.ARR) {
              _this.downLoadHeadPath(item);
            }
          }
        }
        insertDepartmen();
      });
    },

    //通讯录功能点击事件
    setStructureListShow(item, index) {
      this.setBookListShow(index);
      this.$forceUpdate();
      if (item.id == 3) {
        this.$set(item, "structureShow", !item.structureShow);
      } else if (item.id == 4) {
      } else if (item.id == 2) {
        // 获取群列表
        this.getGroupList();
      } else if (item.id == 6) {
      } else {
      }
    },
    /**
     * 点击办公事务列表
     * @param {Num} index 索引
     * @param {bol} bol 是否点击右下角闪烁图标
     */
    setSider(index, bol) {
      console.log(index, 11302);
      this.workIndex = index; //zk1225新增
      console.log(this.unreadMuster, "setsider拿到的未读", index);
      //改变壳头部颜色
      if (index == 3) {
        this.$changeTitleColor("", "#fff");
        console.log("点击工作台");
        this.newSearchShow = true;
        // this.$changeTitleColor("", "#f5f5f5");
      } else {
        this.newSearchShow = false;
        if (index == 2 && bol) {
          this.$changeTitleColor("", "#fff");
        } else {
          this.$changeTitleColor("#fff", "#f7f7f7");
        }
      }
      if (index == 0 && this.b4Leave) {
        //zk新增，切换到聊天并且chating为true，通知服务器端消息已读
        for (let i = 0; i < this.unreadMuster.length; i++) {
          // this.ws.send(
          //   this.$publicSend(this.unreadMuster[i].keys, "1.500", "1.1.1014", {
          //     sendUserId: this.toInfo.id,
          //     receiveUserId: this.myInfo.id,
          //     timestamp: new Date().getTime(),
          //   })
          // ); //zk注释。客户端通知服务器端消息已读
          // this.unreadMuster = [];
          // zk1224修改，触发setSider针对群聊和个人聊天发送已读申请，针对点击角标时的已读
          if (this.toInfo.isGroup == "1") {
            this.ws.send(
              this.$publicSend(this.unreadMuster[i].keys, "1.500", "1.1.2005", {
                sendUserId: this.unreadMuster[i].sendUserId,
                receiveUserId: this.myInfo.id,
                groupId: this.toInfo.id,
              })
            );
            if (i == this.unreadMuster.length - 1) {
              this.unreadMuster = [];
            }
          } else {
            // if (this.chating) {
            //zk新增判断当前聊天框是否激活，激活状态才向服务器端发送已读
            this.ws.send(
              this.$publicSend(this.unreadMuster[i].keys, "1.500", "1.1.1014", {
                sendUserId: this.toInfo.id,
                receiveUserId: this.myInfo.id,
                timestamp: new Date().getTime(),
                isServiceAcc: this.myInfo.authCustservice,
              })
            );
            //// 2022/5/27 zc修改 每次将私聊中所有未读改已读的都发送socket
            if (i == this.unreadMuster.length - 1) {
              this.unreadMuster = [];
            }
            // }
          }
        }
      }
      if (this.sessionList.length == 0) {
        // this.chating=false;//zk注释
        this.setChating(false);
        this.setb4Leave(false);
      }
      for (let i in this.siderArray) {
        this.$set(this.siderArray[i], "active", i == index);
      }
      // // 新增每次点击初始化办公事务
      // if(!bol && this.myInfo.radioOf == 1){//zk1217新增，判断是否有发广播权限
      //   this.workListShow(0);
      // }else{
      //   this.workListShow(1);
      // }
      // 隐藏我的待办弹框
      this.isOpenOfficial = false;
    },
    // 部门数据整合
    openTreeList(id) {
      this.setBookListShow(2, id);
    },
    // 改变部门弹框的显示状态
    changeIsDepartmentShow(bol) {
      this.isDepartmentShow = bol;
    },
    //获取组织结构
    getStructureList(data, success) {
      getGroup(data).then(success);
    },
    //获取置顶列表
    getSetaTop() {
      getSetaTopList({
        userid: this.myInfo.id,
      })
        .then((res) => {
          let arr = {};
          for (let i = 0, len = res.data.length; i < len; i++) {
            arr[res.data[i].objectid] = true;
          }
          this.setaList = arr;
          console.log("获取置顶列表", this.setaList);
          if (this.toInfo) {
            this.topChat = this.get_top_boolean(this.toInfo.id);
          }
          this.sortSessionList();
          this.$forceUpdate();
        })
        .catch((error) => {
          console.warn(error, "err");
        });
    },

    //数据库表初始化
    initCreateTable() {
      // 新增判断表字段是否存在
      // let headPath = "";
      // let isHeadPath = tools.operationalDatabase(`select * from sqlite_master where name = '${this.sqlTable.userInformation}' and sql like '%headPath%';`, 1);
      // if(isHeadPath.list.length == 0) {
      // 	tools.operationalDatabase(`ALTER TABLE ${this.sqlTable.userInformation} ADD COLUMN headPath CHAR(600)  NOT NULL DEFAULT "";`);
      // }else {
      // 	let isPath = tools.operationalDatabase(`SELECT headPath FROM ${this.sqlTable.userInformation} WHERE id = '${this.myInfo.id}';`, 1);
      // 	headPath = isPath.list[0].headPath;
      // };
      // tools.operationalDatabase(
      // 	`REPLACE INTO ${this.sqlTable.userInformation}(id,name,gender,head,account,jobtitle,department,isAdmin,radioOf,groupOf,nickname,headPath) VALUES('${this.myInfo.id}','${this.myInfo.name}','${this.myInfo.gender?this.myInfo.gender:"1"}','${this.myInfo.head}','${this.myInfo.account}','${this.myInfo.jobtitle}','${this.myInfo.departmentname}','${this.myInfo.isAdmin}','${this.myInfo.radioOf}','${this.myInfo.groupOf}','${this.myInfo.nickname}','${headPath}');`
      // );
      // 新增判断用户信息表的详细部门字段departmentnames是否存在
      let isDepartmentnames = tools.operationalDatabase(
        `select * from sqlite_master where name = '${this.sqlTable.userInformation}' and sql like '%departmentnames%';`,
        1
      );
      if (isDepartmentnames.list.length == 0) {
        tools.operationalDatabase(
          `ALTER TABLE ${this.sqlTable.userInformation} ADD COLUMN departmentnames CHAR(600)  NOT NULL DEFAULT "";`
        );
      }
      tools.operationalDatabase(
        `REPLACE INTO ${this.sqlTable.userInformation
        }(id,name,gender,head,account,jobtitle,department,isAdmin,radioOf,groupOf,nickname,departmentnames) VALUES('${this.myInfo.id
        }','${this.myInfo.name}','${this.myInfo.gender ? this.myInfo.gender : "1"
        }','${this.myInfo.head}','${this.myInfo.account}','${this.myInfo.jobtitle
        }','${this.myInfo.departmentname}','${this.myInfo.isAdmin}','${this.myInfo.radioOf
        }','${this.myInfo.groupOf}','${this.myInfo.nickname}','${this.myInfo.departmentnames
        }');`
      );

      tools.allFun(this.sqlTable, this.myInfo);
    },
    // 新增下载头像到本地
    downLoadHeadPath(item, flag) {
      item.head = item.headImage || item.head || item.HEAD || item.HeadImg; //zk0303新增，HeadImg(远程控制头像)
      item.id =
        item.id || item.ID || item.sendId || item.userId || item.LoginID; //zk新增userid,LoginID(远程控制头像)
      let _this = this;
      if (_this.$isNull(item.head)) return; // head是否存在
      let isPath = tools.operationalDatabase(
        `SELECT headPathID,head FROM ${_this.sqlTable.headPathList} WHERE id = '${item.id}';`,
        1
      );
      // console.log(isPath, '查询结果1')
      if (isPath.list.length == 0) {
        // 当前用户是否存在本地数据库 若无就插入用户信息
        let a = tools.operationalDatabase(
          `REPLACE INTO ${_this.sqlTable.headPathList}(id,head) VALUES('${item.id}','${item.head}');`
        );

        isPath = tools.operationalDatabase(
          `SELECT headPathID,head FROM ${_this.sqlTable.headPathList} WHERE id = '${item.id}';`,
          1
        );
      }
      // console.log(isPath, '查询结果2')
      // console.log(item, isPath.list[0], 11226);
      if (item.head != isPath.list[0].head) {
        //zk1218新增，head不相同，修改本地数据库的head
        tools.operationalDatabase(
          `UPDATE ${_this.sqlTable.headPathList} SET head='${item.head}' WHERE id = '${item.id}';`
        );
        // head不相等
        _this.downLoadHeadPathUrl(item);
      } else {
        // head相等
        if (isPath.list[0].headPathID) {
          //if (isPath.list[0].headPathID && isPath.list[0].headPathID.indexOf(":") == -1) {  //切换头像卡顿去掉-1
          // headPath存在
          // if(item.id == _this.myInfo.id && flag == "isMy") {
          // 	_this.$store.commit('setUserInfo', Object.assign(item, {myHeadPath: isPath.list[0].headPath}));
          // 	_this.$delete(item, 'headPath');
          // 	_this.$set(item, 'myHeadPath', isPath.list[0].headPath);
          // }else {
          // 	_this.$delete(item, 'headPath');
          // 	_this.$set(item, 'headPath', isPath.list[0].headPath);
          // }
        } else {
          // headPath不存在
          _this.downLoadHeadPathUrl(item);
        }
      }
    },
    // 头像下载
    downLoadHeadPathUrl(item) {
      const url =
        this.$store.state.url + this.$store.state.imgDownLoadUrl + item.head;
      this.$shell("SaveHeadImage", [
        this.myInfo.id,
        this.sqlTable.headPathList,
        [
          {
            DownUserID: item.id,
            HeadID: item.head,
            DownURL: url,
            Suffix: "PNG",
          },
        ],
      ]);
    },
    /**
     * 头像下载返回
     * @param {num} flagHeadType 新增标记头像需要加载的区域
     * 0: 当前会话记录
     * 1: 群成员
     * 2: 常用联系人
     * 3: 我的部门
     * 4: 全局搜索人员
     * 5: 组织架构or我的部门人员
     * 6: 群重点语录 右侧组件
     * 7: 群重点语录 弹框
     * 8: 我的收藏详情
     */
    HeadDownLoad(id, head, isSuccess, path) {
      path = path.replace(/\/\//g, "/");
      this.$store.commit(
        "setHeadPathUrl",
        path.substring(0, path.lastIndexOf("/") + 1)
      );
      this.$forceUpdate();
    },
    // 全局搜索人员数组
    search_list_array_user(arr) {
      this.flagHeadType = 4;
      this.searchUserList = arr || [];
      this.searchUserList.map((item) => {
        this.downLoadHeadPath(item);
      });
    },
    // 组织架构or我的部门人员数组
    loadingUserList(arr) {
      this.flagHeadType = 5;
      this.orgUserList = arr || [];
      this.orgUserList.map((item) => {
        this.downLoadHeadPath(item);
      });
    },

    activeWindow(info) {
      if (info === "false") {
        this.activeWindowState = false;
      } else {
        this.activeWindowState = true;
      }
    },
    GetLeaveStatus(info) {
      console.log(info, 11313);
      // 0 离开 1 回归 窗口 this.$store.state.user_configure[0].isLeave 时间 this.$store.state.user_configure[0].leaveTime
      if (info == 0) {
        if (this.$store.state.user_configure[0].isLeave == "true") {
          this.check_state_value(2);
        }
      } else {
        if (
          this.$store.state.user_configure[0].isLeave == "true" &&
          this.personalStatus == 2
        ) {
          this.check_state_value(0);
        }
      }
    },
    sendMode() {
      if (this.$store.state.user_hot_key[4] == 1) {
        return true;
      } else {
        return false;
      }
    },
    isFullWindow(info) {
      this.fullState = Number(info); //zk120修改Number
      if (this.fullState == 1) {
        this.activeRecords = false;
      }
    },
    jumpUnread() {
      for (let i = 0; i < this.sessionList.length; i++) {
        if (this.sessionList[i].noRead > 0) {
          this.toChat(this.sessionList[i]);
          return;
        }
      }
    },
    jumpSearch() {
      this.searchResultShow = true;
    },
    hideSearch(info) {
      //zk120x新增，隐藏搜索结果
      this.searchResultShow = info;
    },
    forwardOrcollect(type, item) {
      //type=1表示转发，type=2表示收藏，item消息的详细信息
      if (type == 1) {
        //转发
        this.toForwarding(item);
      } else if (type == 2) {
        //收藏
        this.$refs.homeChatMain.toCollection(item);
      }
    },

    getShareScreenState(res) {
      // console.log('获取同屏状态',res)
      if (this.$route.path == "/") return;
      switch (res) {
        case "1":
          this.$store.state.connectShareScreenServer = false;
          break;
      }
    },

    //zk18新增，远程建立成功通知客户端,res为0失败，为1成功
    remoteHasCollected(res) {
      if (res) {
        this.setControlType(5); //建立连接成功才显示连接成功
      }
    },
    //截屏完成 外壳触发
    screenshot(res) {
      res = JSON.parse(res)
      console.log(res, '12092')
      //子组件监听该值
      this.isScreenshot = res;
    },

    //上传文件列表添加任务
    updateFile(item) {
      this.updateFileList.push(item || []);
      console.log('this.updateFileList啊啊啊啊啊啊啊啊啊',item)
      this.$forceUpdate()
    },
    // 共享文件分享文件
    shareFile(info) {
      console.log(info, "shareFile");
      if (info) {
        this.modalTitle = 7;
        this.modalFirst = true;
        this.shareFileArr = JSON.parse(info);
      }
    },

    // 公文管理调用父页面的方法
    official(info) {
      // 服务于分享文件
      if (info == 1) {
        // 点击公文关闭按钮
        //this.workListShow(0);
        this.workList.forEach((val, index) => {
          val.show = false;
        });
        this.setSider(3);
      }
    },
    /**
     * 初始化组织架构
     * @param {Array} id 部门ID集合
     */
    getTreeList(id) {
      this.flagHeadType = 5;
      if (id) {
        this.getStructureList({}, (info) => {
          // 点击个人会话跳转到组织架构
          this.returnTreeList(id, info.data);
        });
      } else {
        this.getStructureList({}, (info) => {
          for (let i in info.data) {
            info.data[i].checked = false;
          }
          this.$store.state.tree.list = info.data;
          this.$set(this.bookList[2], "structureList", info.data);
          this.$set(this.modalFirstList[2], "structureList", info.data);
          this.$forceUpdate();
        });
      }
    },
    // 点击个人会话跳转到组织架构（同级的循环完，再循环下一级）
    returnTreeList(arr, data, bol) {
      if (!bol) this.treeList = data;
      this.getStructureList({ fid: arr[0] }, (info) => {
        for (let i in data) {
          data[i].checked = false;
          if (data[i].FID && data[i].FID == arr[0]) {
            this.$set(data[i], "open", true);
            this.$set(data[i], "child", info.data);
            arr.splice(0, 1);
            if (arr.length > 0) {
              this.returnTreeList(arr, data[i].child, true);
            } else {
              this.$set(this.bookList[2], "structureList", this.treeList);
              this.$forceUpdate();
            }
          }
        }
      });
    },
    // 存储我的文章
    installArticle(data) {
      console.log(data, 11459);
      let flag = false;
      let isGroup = "0";
      let type = "article";
      let duration = null;
      let isDownLoad = null;
      let DownLoadId = null;
      let fontSize = null;
      let isRead = 1;
      let receiveUserList = data.receiveUser.filter(
        (item) => (item.id || item.ID) != this.myInfo.id
      );

      let receiveUsers = data.receiveUser
        .filter((t) => (t.id || item.ID) != data.sendId)
        .map((t) => t.name)
        .join();

      console.log(receiveUsers, 11609);
      // 判断是否存在这条内容
      let isMsgId = tools.operationalDatabase(
        `SELECT COUNT(1) FROM ${this.sqlTable.articleList} WHERE articleMessage='${data.articleId}'`,
        1
      );
      if (isMsgId.success && isMsgId.list[0]["COUNT(1)"] == 0) {
        // 存储到本地数据库文章表
        console.log("存入本地数据库");
        tools.operationalDatabase(`REPLACE INTO ${this.sqlTable.articleList}
						(sendName,sendId,receiveUser,articleTitle,articleUrl,articleMessage,articleEditor,articleImgUrl,time) VALUES
						('${data.sendName}','${data.sendId}','${data.sendId == this.myInfo.id ? receiveUsers : ""
          }','${data.title}','${data.articleLink}','${data.articleId}','${data.describe
          }','${data.picture}','${data.updateDate ? data.updateDate : new Date().getTime()
          }')`);
      }
      // 获取我的文章列表
      // console.log(this.$refs.myArticle, 11595);
      if (this.$refs.myArticle) {
        this.$refs.myArticle.articleSearchFn();
      }
      // 判断是否为自己发送的文章
      if (data.sendId != this.myInfo.id) {
        receiveUserList = [this.myInfo];
      }
      let messageId;
      try {
        messageId = JSON.parse(data.messageIds);
      } catch (error) {
        messageId = data.messageIds;
      }

      for (let i in receiveUserList) {
        // let messageId = this.$func.uuid();

        for (let j in messageId) {
          if ((receiveUserList[i].id || receiveUserList[i].ID) == j) {
            // 存储到本地数据库消息列表
            this.insertData(
              data.sendName,
              receiveUserList[i].id || receiveUserList[i].ID,
              data.sendId,
              type,
              JSON.stringify({
                isArticle: data.isArticle,
                title: data.title,
                url: data.articleLink,
                describe: data.describe,
                imgUrl: data.picture,
                messageId: messageId[j],
              }),
              data.updateDate ? data.updateDate : new Date().getTime(),
              messageId[j],
              isRead,
              "0",
              isDownLoad,
              DownLoadId,
              duration,
              isGroup,
              fontSize,
              data.head,
              "",
              0,
              0
              // data.gender
            );

            // 更新消息列表
            this.updateSessionChat(
              data.sendId,
              receiveUserList[i].id || receiveUserList[i].ID,
              data.sendName,
              receiveUserList[i].name,
              {
                isArticle: data.isArticle,
                title: data.title,
                url: data.articleLink,
                describe: data.describe,
                imgUrl: data.picture,
                messageId: messageId[j],
              },
              data.updateDate ? data.updateDate : new Date().getTime(),
              isGroup,
              messageId[j],
              type,
              duration,
              isDownLoad,
              DownLoadId,
              isRead,
              fontSize,
              data.gender,
              data.head
            );
          }
        }
      }
    },

    /**
     *    是否检测到升级程序
     * bol 普通升级 布尔值
     * update 强制升级 布尔值
     */
    isUpdateExe(bol, update) {
      console.log(bol, update, "是否触发升级");
      bol = bol == "false" ? false : true;
      update = update == "false" ? false : true;
      if (bol) {
        this.updateExe = false; // 强制升级弹框
        this.isUpdateExeShow = true; // 普通升级弹框
        if (update) {
          this.updateExe = true;
          this.isUpdateExeShow = false;
          // this.updateExeFn()//zk0201新增，下载完更新之后重启，暂时不用
        }
      }
      this.$forceUpdate();
    },
    // 头像上传窗体显示接口
    showUpdatePicForm(downLoadId) {
      let long = this.myInfo.id.length;
      let long2 = this.$store.state.headPathUrl.length;
      let headDUrl = this.$store.state.headPathUrl.substr(0, long2 - long - 20);
      console.log(headDUrl, 16593);
      let path = this.$isNull(this.myInfo.headImage)
        ? `${headDUrl}dist/static/image/home/person_${this.myInfo.gender == 1 ? 1 : 2
        }_big.png`
        : `${this.$store.state.headPathUrl}${this.myInfo.id}${this.myInfo.headImage}.PNG`;
      let info = this.$shell("OpenUpdateHeadImageForm", [
        this.myInfo.id,
        downLoadId,
        this.$isRelativePath(path),
        this.myInfo.gender,
      ]); //zk1225修改showUpdatePicForm -> OpenUpdateHeadImageForm
      console.log(info, "头像上传窗体显示接口返回");
    },
    /**
     * 重新发送失败的消息
     */
    againSendFailMsg(isManually) {
      console.log(isManually, 11623);
      //zk修改，重发消息时，将新消息置于底部
      if (isManually && this.isOnline) {
        // 手动点击发送失败的消息
        let tab =
          isManually.isGroup == 1
            ? this.sqlTable.messageList
            : this.sqlTable.privateList;
        let msg = tools.operationalDatabase(
          `SELECT * FROM ${tab} WHERE messageId = '${isManually.messageId}';`,
          1
        );
        // 再次发送失败的消息 更新历史记录发送状态
        for (let item of this.chatList[1]) {
          if (item.messageId == isManually.messageId) {
            this.$set(item, "isSuccessSend", 1);
            this.$set(item, "isByRead", "0"); //zk新增，重发消息时，视图上将消息状态改为未读
            break;
          }
        }

        console.log(msg, 11644);
        // 循环再次发送失败的消息
        if (msg.list && msg.list.length > 0) this.circulationMsg(msg.list, tab);
      }
    },
    // 循环再次发送失败的消息
    circulationMsg(arr, type) {
      console.log(arr, type, "失败消息列表");
      for (let item of arr) {
        let commonObj = {
          id: item.DownLoadId,
          size: item.duration,
          name: item.value,
          duration: item.duration,
        };
        let isText =
          item.type == "text" ? { text: this.textMsg(item.value) } : {};

        let isImage = item.type == "image" ? commonObj : {};
        let isFile =
          item.type == "file"
            ? Object.assign(commonObj, {
              isDownLoad: "0",
              DownLoadId: item.DownLoadId,
            })
            : {};

        if (item.type == "image" && item.DownLoadId == "1") {
          //截图重发
          let blobFile = this.$utilJs.dataURItoBlob(item.rawValue);
          let form = new FormData();
          form.append("file", blobFile);
          form.append("userid", this.myInfo.id);
          form.append("toid", item.receiveId);
          form.append("toname", item.name);
          form.append("isScreenshot", 1);
          this.$upload(
            "api/v1/oim/image/upload.do",
            form,
            (info) => {
              if (info.result == 4) {
                //上传失败
                this.$set(item, "isSuccessSend", 2);
                return;
              }
              tools.operationalDatabase(
                `UPDATE ${type}
                SET DownLoadId = '${info.data.id}'
                WHERE messageId = '${item.messageId};`,
                1
              );
              this.$wsSendMsg(
                this.toInfo,
                item.messageId,
                "image",
                {
                  id: info.data.id,
                  size: info.data.size,
                  name: this.myInfo.id + new Date().getTime() + ".jpg",
                  duration: 32,
                  gender: this.myInfo.gender || "1",
                  head: this.myInfo.headImage || "",
                },
                this.ws
              );
            },
            (err) => {
              console.warn("error");
            }
          );
        } else {
          console.log(11715);
          this.$wsSendMsg(
            this.toInfo,
            item.messageId,
            item.type,
            Object.assign(isText, isImage, isFile, {
              gender: this.myInfo.gender,
              head: this.myInfo.head,
            }),
            this.ws
          );
        }
      }
    },
    // 删除某条语录
    delteleQuotation(id) {
      console.log(id, "需要删除的id");
      this.ws.send(this.$publicSend(id, "1.500", "1.1.2007", { id: id }));
    },

    // 全部语录弹窗关闭
    dialogClose() {
      // this.allText = false
      // 关闭的同时将获取语录的数据置为当前群的数据
      let key = this.toInfo.id;
      let page = {
        pageSize: 30,
        pageNumber: 1,
      };
      this.ws.send(
        this.$publicSend(key, "1.500", "1.1.2008", { groupId: key, page })
      );
    },

    // 组件搜索=关键字
    searchKeyWords(keys) {
      console.log(keys, "keys");
      let page = {
        pageSize: 30,
        pageNumber: 1,
      };
      let key = this.toInfo.id;
      if (!keys) {
        this.ws.send(
          this.$publicSend(key, "1.500", "1.1.2008", {
            groupId: this.toInfo.id,
            page: page,
          })
        );
      }
      this.ws.send(
        this.$publicSend(key, "1.500", "1.1.2008", {
          groupId: this.toInfo.id,
          page: page,
          name: keys,
        })
      );
    },
    //上传本地备份数据库请求
    isUpdateStart() {
      console.log("在调用了备份接口1");
      selectUserTask({
        userId: this.myInfo.id,
        iutClient: 1,
      }).then((res) => {
        console.log("进入备份接口ing");
        console.log(res);
        if (res.data) {
          this.updateItem = res.data;
          this.updateConfirm(res.data.IUTID, 1);
        }
      });
    },
    //上传本地备份数据库开始或结束
    updateConfirm(id, state) {
      console.log("在调用了确认接口2");
      insertUserTaskLog({
        userId: this.myInfo.id,
        iutlClient: 1,
        iutId: id,
        iutlState: state,
      }).then((res) => {
        console.log("进入了确认接口ing2");
        if (res.msg == "success") {
          this.isUpdateCount++;
          console.log("在调用了确认接口success", this.isUpdateCount);
          // this.$store.commit("setIsUpBack", this.isUpdateCount);
          if (state == 1) {
            this.getUpdateMsgCount(
              this.updateItem.STARTDATE,
              this.updateItem.ENDDATE
            );
            this.upDateMsg(this.updateItem.STARTDATE, this.updateItem.ENDDATE);
          }
        }
      });
    },
    //上传聊天记录到服务器
    upDateMsg(startTime, endTime) {
      let updataPage = JSON.parse(
        window.localStorage.getItem(`updataPage${this.myInfo.id}`)
      );
      if (updataPage == null) {
        this.updateConfirm(this.updateItem.IUTID, 2);
        return false;
      }
      let nowPage = updataPage.nowPage;
      let total = updataPage.total;
      let arr = this.getUpdateMsg(startTime, endTime, nowPage);
      if (nowPage > total) {
        this.updateConfirm(this.updateItem.IUTID, 2);
        return false;
      }
      charRecord({
        list: JSON.stringify(arr),
        id: this.updateItem.IUTID,
      }).then((res) => {
        nowPage++;
        window.localStorage.setItem(
          `updataPage${this.myInfo.id}`,
          JSON.stringify({ total: total, nowPage: nowPage })
        );
        if (nowPage <= total) {
          this.upDateMsg(startTime, endTime);
        } else {
          this.updateConfirm(this.updateItem.IUTID, 2);
          return;
        }
      });
    },
    //获取本地消息上传任务
    getUpdateMsg(startTime, endTime, page) {
      //tools.operationalDatabase
      let sql1 = `SELECT 'false' isGroup,	_id	id,messageId	messageKey,sendId	sendUserId,receiveId	receiveUserId,fontSize	font,	type	type,	value	value,time	timestamp	FROM	${this.sqlTable.privateList}	WHERE sendId = ${this.myInfo.id} AND time> ${startTime} AND time < ${endTime}`;
      let sql2 = `SELECT 'true' isGroup,	_id	id,messageId	messageKey,sendId	sendUserId,receiveId	receiveUserId,fontSize	font,	type	type,	value	value,time	timestamp	FROM	${this.sqlTable.messageList}	WHERE	sendId = ${this.myInfo.id} AND time> ${startTime} AND time < ${endTime}`;
      let sql3 = `SELECT * FROM (${sql1} UNION ${sql2}) LIMIT	${(page - 1) * 100
        },100`;
      let Msg = tools.operationalDatabase(sql3, 1);
      return this.$utilJs.formatMsg(Msg, this.myInfo.name);
    },
    //获取消息条数
    getUpdateMsgCount(startTime, endTime) {
      let sql = `SELECT	*	FROM	${this.sqlTable.privateList}	WHERE	sendId = ${this.myInfo.id} AND time>${startTime} AND time<${endTime}`;
      let sql1 = `SELECT	*	FROM	${this.sqlTable.messageList}	WHERE	sendId = ${this.myInfo.id} AND time>${startTime} AND time<${endTime}`;
      let count = tools.operationalDatabase(sql, 1).list.length;
      let count1 = tools.operationalDatabase(sql1, 1).list.length;
      let total = Math.ceil((count + count1) / 100);
      window.localStorage.setItem(
        `updataPage${this.myInfo.id}`,
        JSON.stringify({ total: total, nowPage: 1 })
      );
    },
    //展示右下角消息闪烁，新
    showTips() {
      // unNoticeArr
      let arry = [];
      if (this.messageTipsArr) {
        for (let i in this.messageTipsArr) {
          arry.push(this.messageTipsArr[i][this.messageTipsArr[i].length - 1]);
        }
      }
      console.log("拿到闪烁消息", arry, this.messageTipsArr);
      let res = this.$shell("GetNewInfo_New", [arry, "getNewInfo"]);
    },
    //清空消息闪烁
    cleanMessageTips() {
      console.log("清空消息闪烁");
      this.messageTipsArr = null;
      this.showTips();
    },
    //删除当前闪烁项
    delCurMessageTips(i) {
      if (this.messageTipsArr) {
        if (i in this.messageTipsArr) {
          delete this.messageTipsArr[i];
          this.showTips();
        }
      }
    },
    itemNext(i) {
      let n =
        this.detailArray.data.findIndex((i) => i.messageId == this.recordId) +
        i;
      this.showRecords(true, this.detailArray.data[n]);
    },
    // 被邀请同屏参数接收
    receiveScreen(info) {
      this.screenViwe_show = true;
      this.isInviter = false;
      this.receiveScreenMsg = JSON.parse(info);
      console.log(info, "被邀请同屏参数接收");
    },
    //打开综合搜索标签页
    openSearchTab(e, val) {
      this.isSearchShow = true;
      this.$refs.cSearchShow.addAppFn(e, val);
    },
    //综合搜索转跳群搜索、名片搜索
    openBookList(n) {
      this.setSider(1);
      this.setBookListShow(n);
      this.searchResultShow = false;
    },
    //综合搜索跳转应用
    openListShow(n) {
      this.setSider(3);
      this.searchResultShow = false;
      if (n) {
        this.openApp(n);
      }
    },
    //当前聊天回到底部
    backBottom() {
      this.chatList = [[], []];
      this.currentTempChat = [[], []];
      this.chatMsgPage = 0;
      this.havenext = false;
      this.$forceUpdate();
      this.getMessageRecord();
    },
    //聊天窗滚动到底部
    chatScrollToBottom() {
      this.$forceUpdate()
      this.$nextTick(()=>{
        if(this.$refs['homeChatMain']){
          this.$refs['homeChatMain'].scrollToBottom()
        }
      })
    },
    //获取默认路径
    getDefultPath(res) {

      console.log(res, 12516);
      // console.log('获取默认路径1',res)
      res = res.replace(/\\/g, "/");
      // console.log('获取默认路径2',res)
      this.$store.commit("setDefultPath", res);
    },
    //操作dom事件
    domFn() {
      let _this = this;
      //阻止回车默认事件
      $(window).keydown(function (e) {
        var key = window.event ? e.keyCode : e.which;
        /*获取用户按键，如果是回车，则不执行任何*/
        if (key.toString() == "13") {
          if (_this.sendMode()) {
            e.preventDefault();
          }
        }
      });
      //转发窗口拖拽 czx
      $(".ivu-modal-content-drag").mousemove(function (e) {
        let temp = $(".ivu-modal-content-drag");
        let left = temp.offset().left;
        let top = temp.offset().top;
        let h = temp.height();
        let w = temp.width();

        let bh = $("body").css("height");
        bh = Number(bh.substr(0, bh.length - 2));
        let bw = $("body").css("width");
        bw = Number(bw.substr(0, bw.length - 2));
        let ww = bw - w;
        let hh = bh - h;
        if (left < 0) {
          temp.css({
            left: 0,
          });
        }
        if (top < 0) {
          temp.css({
            top: "-50px",
          });
        }
        if (left > ww) {
          temp.css({
            left: ww + "px",
          });
        }
        if (top > hh) {
          temp.css({
            top: hh - 50 + "px",
          });
        }
      });
      // //阻止下拉列表失去焦点
      // document.addEventListener(
      //   "mousedown",
      //   function(e) {
      //     if ($(e.target).closest("#tree123").length > 0) {
      //       $("#departinput").unbind("blur");
      //     } else {
      //       $("#departinput").blur(() => {
      //         _this.showTree = false;
      //         return false;
      //       });
      //     }
      //   },
      //   false
      // );
      window.addEventListener("offline", () => {
        console.log("网络断开了");
        if (this.isOnline) {
          this.isOnline = false;
          this.sessionList.forEach((item) => {
            item.offline = false;
          });
        }
      });
      window.addEventListener("online", () => {
        console.log("网络连上了");
        if (!this.isOnline) {
          this.isOnline = true;
        }
      });
    },
    //获取热键
    getHotKey() {
      let user_hot = tools.operationalDatabase(
        `SELECT * FROM ${this.sqlTable.userHotKey} WHERE id='${this.myInfo.id}';`,
        1
      );

      console.log(user_hot, 17105);
      if (user_hot.list.length == 0) {
        let getPath = this.$shell("GetDefultLoacalPath", [this.myInfo.id]);
        getPath = getPath.replace(/\\/g, "\\\\");
        getPath = JSON.parse(getPath);
        let pathUrl = "";
        if (getPath.return_code == "TRUE") {
          pathUrl = getPath.return_msg;
        }
        this.$store.state.user_hot_key[5] = pathUrl;

        console.log(pathUrl, 12617);
        this.getDefultPath(pathUrl);
        tools.operationalDatabase(
          `REPLACE INTO user_hot_key(id,search,screen,session,window,send,path) VALUES('${this.myInfo.id}',"Alt+Q","Alt+A","Alt+R","Ctrl+W","1",'${pathUrl}');`
        );
      } else {
        let res = user_hot.list[0];
        this.$store.state.user_hot_key = [
          res.search,
          res.screen,
          res.session,
          res.window,
          res.send,
          res.path ? res.path : pathUrl,
        ];
        console.log(res, 12634);
        this.getDefultPath(res.path ? res.path : pathUrl);
      }
      this.senHot = this.$store.state.user_hot_key[4];
      for (let i in this.$store.state.user_hot_key) {
        if (i != 4) {
          let dat = this.$store.state.user_hot_key[i];
          let rre;
          if (i == 3) {
            rre = this.$shell("HotKeyRegister", [
              i + "",
              "TRUE",
              dat,
              "ActivateMainForm",
            ]);
          } else if (i == 2) {
            //跳转
            rre = this.$shell("HotKeyRegister", [
              i + "",
              "TRUE",
              dat,
              "jumpUnread",
            ]);
          } else if (i == 0) {
            //搜索
            rre = this.$shell("HotKeyRegister", [
              i + "",
              "TRUE",
              dat,
              "jumpSearch",
            ]);
          } else if (i == 1) {
            //zk15标识，截图快捷键
            rre = this.$shell("HotKeyRegister", [
              i + "",
              "TRUE",
              dat,
              "screenshot",
            ]);
          }
        }
      }
      this.$store.commit("setInitQCode", "");
      this.$forceUpdate();
    },
    //主页组织架构选择下一项
    tonextstr(e, item, index) {
      if (this.clickIntervale) {
        window.clearTimeout(this.clickIntervale);
        this.clickIntervale = null;
      }
      this.clickIntervale = setTimeout(() => {
        this.getCurCoor(e);
        if (item.NO && item.NO != this.myInfo.id) {
          let info = tools.operationalDatabase(
            `SELECT * FROM ${this.sqlTable.userInformation} WHERE id='${item.NO}'`,
            1
          );
          getUserInfo_axios({
            userid: item.NO,
          })
            .then((res) => {
              if (res.result == 200) {
                this.viewTarget = res.data;
                this.isLinkman();
                this.viewTargetShow = true;
                let msg = res.data;
                let job = msg.jobtitle == null ? "" : msg.jobtitle;
                let depart =
                  msg.departmentname == null ? "" : msg.departmentname;
                let head = info.list[0] ? info.list[0].head : "";
                if (head != msg.head && msg.head != null) {
                  // this.$downLoad("api/v1/oim/head/user/download.do", head, (data) => {
                  // 	console.log('下载结果')
                  // 	console.log(data)
                  // }, (data) => {
                  // 	console.log('error')
                  // 	console.log(data)
                  // })
                } else {
                  tools.operationalDatabase(
                    `REPLACE INTO ${this.sqlTable.userInformation}(id,name,gender,head,account,jobtitle,department,isAdmin,radioOf,groupOf,nickname) VALUES ('${msg.id}','${msg.name}','${msg.gender}','${msg.head}','${msg.account}','${job}','${depart}','${msg.isAdmin}','${msg.radioOf}','${msg.groupOf}','${msg.nickname}');`
                  );
                }
                // 新增下载头像
                this.downLoadHeadPath(this.viewTarget);
              } else {
                console.log(res.result);
              }
            })
            .catch((res) => {
              if (info.list[0]) this.viewTarget = info.list[0];
              // 新增下载头像
              this.downLoadHeadPath(this.viewTarget);
            });
        } else if (item.FID) {
          this.viewTarget = null;
          this.viewTargetShow = false;
          this.currentStructureName.push(item);
          this.currentStructureIndex++;
          this.getNextCurNext(item.FID);
        } else if (item.NO == this.myInfo.id) {
          this.viewTargetShow = false;
        }
      }, 300);
    },
    //注册全局事件
    windowFn() {
      let arr1 = [
        "forwardOrcollect",
        "exitLogin",
        "screenshot",
        "remoteHasCollected",
        "jumpSearch",
        "jumpUnread",
        "isFullWindow",
        "activeWindow",
        "GetLeaveStatus",
        "shareFile",
        "official",
        "tonextstr",
        "dbtoNewChats",
        "isUpdateExe", //
        "HeadDownLoad",
        "loadingUserList",
        "cleanMessageTips",
        "receiveScreen",
        "getShareScreenState",
      ];
      arr1.forEach((i) => {
        window[i] = this[i];
      });
    },
    //多拉取几次离线
    sendOfflineFn() {
      this.$getOffline();
      let t = 60000 * this.offlineInterval[this.setNum];
      clearInterval(window.sendOffline);
      if (this.setNum < this.offlineInterval.length) {
        this.setNum++;
        console.log('推送之前');
        window.sendOffline = setTimeout(() => {
          this.sendOfflineFn();
        }, t);
      }
    },
    //图片下载完找到替换
    findPicId(id, path) {
      for (let i in this.currentTempChat) {
        for (let j in this.currentTempChat[i]) {
          if (this.currentTempChat[i][j].messageId == id) {
            this.$set(this.currentTempChat[i][j], "value", path);
            return;
          }
        }
      }
    },
    NetdiskState() {
      console.log('ntalk 分享成功');
    },
  },
  created() {
    window.downLoadHeadPathUrl = this.downLoadHeadPathUrl;
    this.initData(null);
    this.initCreateTable();
    this.programmeTimeInit();
    this.getDisturb(); // 获取免打扰
    this.windowFn();
    console.log(window.tonextstr, 12186);
    window.getSessionList = this.getSessionList;
    window.getseessionListTest = this.getseessionListTest;
    window.NetdiskState = this.NetdiskState
  },
  mounted() {

    //开启时，过渡页获取公文信息
    let l = this.$shell("GetDB", []);
    let dbinfo = null;
    if (l.Return_code) {
      if (l.V1) dbinfo = l.V1;
    }

    console.log("第一次拉取离线");
    this.$getOffline();
    //如果离线报文没拉取到，多发送几次
    setTimeout(() => {
      console.log("第二次拉取离线");
      this.sendOfflineFn();
    }, 5000);
    // 第一次拉库
    this.getSessionList();


    // setTimeout(()=>{
    //   this.sessionList = this.init_session_list();
    // },500)
    let myinfo = tools.operationalDatabase(
      `SELECT * FROM ${this.sqlTable.userInformation} WHERE id='${this.myInfo.id}';`,
      1
    );
    this.$store.state.myInfo = Object.assign(
      this.$store.state.myInfo,
      myinfo.list[0]
    );
    this.ws.send(
      this.$publicSend(this.$func.uuid(), "1.500", "1.1.1015", {
        userId: this.myInfo.id,
      })
    );
    this.$nextTick(() => {
      //页面开启
      this.$changeTitleColor("#fff", "#f7f7f7");
      this.$shell("SetLoginUser", [
        this.myInfo.account,
        this.myInfo.name,
        "",
        window.screen.availWidth <= 1366
          ? parseInt(window.screen.availWidth * 0.9) + ""
          : parseInt(window.screen.availWidth * 0.7) + "",
        window.screen.availHeight <= 768
          ? parseInt(window.screen.availHeight * 0.85) + ""
          : parseInt(window.screen.availHeight * 0.8) + "",
      ]);
      let changeShow = this.$shell("ChangeFormShow", ["0"]);
      this.$store.commit("set_soketConnect", false);
      this.getHotKey();
      //修改位置
      this.setChating(false);
      this.setb4Leave(false);
      //zk新增,初始化选定时间
      this.lastClickTime = this.$utilJs.getDating().substring(0, 10);
      this.createSystemTable();
      this.systemInit();
      let _this = this;
      document.addEventListener("click", () => {
        _this.minorShow = false;
        // _this.isOpenOfficial = false;//zk1225新增，点击框体隐藏待办
      });
      // 2022/5/7 zc取消加载获取群，已在session_list_sider获取一次
      // this.getGroupUser(); //获取我的群

      // 判断窗口大小
      this.screenWidth = document.body.clientWidth;
      this.screenHeight = document.body.clientHeight;
      window.onresize = () => {
        return (() => {
          this.screenWidth = document.body.clientWidth;
          this.screenHeight = document.body.clientHeight;
        })();
      };

      //setInterval(this.isUpdateStart(), 900000);
      // 2022/7/19 修改 将跳转公文页设置显示时长与关闭按钮 此前为0不消失
      if (dbinfo) {
        this.$Message.info({
          content: "转跳公文页面中，请稍等",
          duration: 5000,
          showClose: true,
        });
      }
      // this.getDefultPath()

      setTimeout(() => {
        this.getSchedule("init"); //需初始化定时器
        this.login1 = true;
      }, 10);

      setTimeout(() => {
        this.getRemind(); //获取初始化待办列表
        this.getSetaTop(); // 获取置顶
        this.getSystemConfigure();
      }, 600);

      setTimeout(() => {
        this.login2 = true;
        // 2022/7/8 修改在登陆时获取收藏入库，避免点击我的收藏是入库和拉库同时，渲染过慢
        this.getCollect();
        this.getSessionBroad();
        this.domFn();
        // 2022/5/7 zc修改 首次登陆不发送获取常用联系人与组织架构请求
        // this.getTreeAndUserCategory();
        if (dbinfo) {
          this.setSider(2);
          this.workListShow(5);
          sessionStorage.setItem("dbinfo", dbinfo);
        }
      }, 1100);

      setTimeout(() => {
        // zk0220新增远程控制下载头像
        this.$bus.$on("downHeadImg", (user) => {
          // console.log(user,"收到的参数");
          this.downLoadHeadPath(user);
        });
        // zk0303新增，直接远程
        this.$bus.$on("dirRemote", (type, id) => {
          let initid = this.$func.uuid();
          this.ws.send(
            this.$publicSend(initid, "1.101", "1.1.0016", {
              userId: id,
            })
          );
          this.$store.commit("Is_MacAddress_Common", type);
          this.controlFn(type, id);
        });
        this.$bus.$on("showDeviceInfo", (info) => {
          console.log(info, "接收到的设备信息");
          this.deviceInfo = info;
          this.deviceInfoShow = true;
        });
        //zk新增，监听中央事件总线的重连
        this.$bus.$on("isConnected", (msg) => {
          console.log(msg);
          this.getSessionList();
        });
        //综合搜索消息跳转
        this.$bus.$on("goChatMsg", (a, b) => {
          console.log(a, b);
          this.searchMdbTochat(a);
          this.switchChatMain(b);
        });
        // this.getDefaultRemoteArr();//zk129新增，获取当前账号所有的可自动远程分组成员
        // zk129新增，进入时检测更新,暂时不用
        // let needUpdate = this.$shell("ManualUpdate",["0"])
        // console.log(needUpdate,"检测是否需要更新")
        // if(needUpdate.IsNeedUpdate){
        //   this.showNewVersion = true
        //   let info = this.$shell("GetNewestVersion",[])
        //   this.newVersionDetail = JSON.parse(info.V1)
        // }
        // 连接同屏中转服务器
        // this.$remoteControlConnect()
        // console.log("连接远程控制服务器",this.$store.state.connectRemoteServer);
      }, 8000);
    });

    // 2022/5/7 zc新增 定时器每半小时查一次公文数量
    const timer = setInterval(() => {
      this.getOfficial();
    }, 1000 * 60 * 30);

    // 通过$once来监听定时器，在beforeDestroy钩子可以被清除
    this.$once("hook:beforeDestroy", () => {
      // 在页面销毁时，销毁定时器
      clearInterval(timer);
    });
  },
};
</script>
<style lang="less" scoped>
.page_wrap {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  text-align: center;
}

.ivu-page {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
}

.goto_w {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
}

.goto_w>input {
  border-radius: 5px;
  border: 1px solid #ddd;
  width: 50px;
  margin: 0 10px;
  text-align: center;
  height: 32px;
}

.goto_w>button {
  border: 1px solid #ddd;
  height: 32px;
  line-height: 32px;
  padding: 0 5px;
  border-radius: 5px;
  outline: 0;
  background: #fff;
  cursor: pointer;
}

.loading_structure {
  position: relative;

  .right_menu {
    position: absolute;
    z-index: 1009;
    background-color: #fff;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 0 3px 1px #ccc;

    li {
      line-height: 22px;
      cursor: pointer;

      &:hover {
        color: #fa7500;
      }
    }
  }
}

.f_v_t_margin {
  margin-right: 5px;
  margin-bottom: 3px;
}
</style>
